Îõ³h& )  Safe-InferredÜï foldl-exceptionsúPerforms the steps of a fold up until the first step that throws an exception, then produces the result obtained thus far.Exampleimport Control.Exception1f x = if x < 10 then return x else throw Overflow xs = [1, 2, 500, 4] :: [Integer]Since f 5001 produces an exception, the following fold fails:#fold1 = premapM f (generalize list)foldM fold1 xs"*** Exception: arithmetic overflow By applying untilFirstExceptioné, we can produce a new fold that returns the intermediate result at the point where the exception occurs.fold2 = exHalt_ fold1foldM fold2 xs[1,2]foldl-exceptionsðPerforms the steps of a fold up until the first step that throws an exception, then produces a tuple containing: &The exception that was thrown, if any.The result obtained thus far.The first type parameter lets you specify what type of exception to catch. Any other type of exception will still cause the entire fold's evaluation to fail.Exampleimport Control.Exception1f x = if x < 10 then return x else throw Overflow xs = [1, 2, 500, 4] :: [Integer]#fold1 = premapM f (generalize list):set -XTypeApplications$fold2 = exHalt @ArithException fold1foldM fold2 xs (Just arithmetic overflow,[1,2])foldl-exceptionsÈPerform only steps of a fold that succeed, ignoring any steps that fail.Exampleimport Control.Exception1f x = if x < 10 then return x else throw Overflow xs = [1, 2, 500, 4] :: [Integer]Since f 5001 produces an exception, the following fold fails:#fold1 = premapM f (generalize list)foldM fold1 xs"*** Exception: arithmetic overflow By applying Ç, we can produce a new fold that produces a result from all steps that don't fail:fold2 = exSkip_ fold1foldM fold2 xs[1,2,4]foldl-exceptions‚Perform only steps of a fold that succeed, collecting the exceptions thrown from each step that fail. Produces a tuple containing:  A list of any exceptions thrown.2The result obtained from the steps that succeeded.The first type parameter lets you specify what type of exception to catch. Any other type of exception will still cause the entire fold's evaluation to fail.Exampleimport Control.Exception1f x = if x < 10 then return x else throw Overflow xs = [1, 2, 500, 4] :: [Integer]Since f 5001 produces an exception, the following fold fails:#fold1 = premapM f (generalize list)foldM fold1 xs"*** Exception: arithmetic overflow By applying Ç, we can produce a new fold that produces a result from all steps that don't fail::set -XTypeApplications$fold2 = exSkip @ArithException fold1foldM fold2 xs([arithmetic overflow],[1,2,4])/foldl-exceptions-1.0.0.2-E9fACN3qj3LHux9Z6Fe1stControl.Foldl.ExceptionsexHalt_exHaltexSkip_exSkip