h$j      Safe-Inferred 2errorThe canonical Error type. It can be-created from a human-readable error message ()2more semantic context can be added to an existing Error ()pretty-printed ()errorCreate an ad-hoc  from an error message.errorCreate an error from a  type.If your type implements , it is usually better to use  instead. Strings produced by $ are usually not very user-friendly.Note: goes via , so not efficient.errorCreate an error from an  type.The default implementation of  is ,, so the same user-friendliness problems of  apply.Note: goes via , so not efficient.error!Add a higher-level context to an .For example, your code hits a @file not found@ I/O exception. Instead of propagating it unseen, you catch it and annotate it with , and describe why you wanted to open the file in the first place: addContext "Trying to open config file" $ newError "file not found: ./foo" This way, when a user see the error, they will understand better what happened: 4"Trying to open config file: file not found: ./foo" See .errorPretty print the error.It will print all context messages, starting with the outermost.Example:.prettyError $ newError "file not found: ./foo""file not found: ./foo":{ prettyError- $ addContext "Trying to open config file"( $ newError "file not found: ./foo":}3"Trying to open config file: file not found: ./foo"error8Return the value from a potentially failing computation.Abort with the s message if it was a .Panics: if ErrorExample:&unwrapError $ Left (newError "oh no!")*** Exception: oh no!...unwrapError $ Right 4242error8Return the value from a potentially failing computation.0Abort with the error message if it was an error.!The text message is added to the ' as additional context before aborting.Panics: if ErrorExample:?expectError "something bad happened" $ Left (newError "oh no!")-*** Exception: something bad happened: oh no!.../expectError "something bad happened" $ Right 4242errorLike , but instead of using  , it will  the pretty-printed error.The advantage over 7 is that it crashes immediately, and not just when the  is forced, leading to a deterministic immediate abortion of your IO code ( 7https://github.com/ghc-proposals/ghc-proposals/pull/3301but no stack trace can be produced at the moment!).Throws opaque Exception: if ErrorExample:(unwrapIOError $ Left (newError "oh no!")*** Exception: oh no! Important:  itself does not implement , to discourage the exception workflow. The  thrown is private to this module and thus can@t be @caught@ in a typed manner. If you use this function, you either have to catch :, or it will bubble up and lead to your program crashing. errorLike , but instead of using  , it will  the pretty-printed error.The advantage over 7 is that it crashes immediately, and not just when the  is forced, leading to a deterministic immediate abortion of your IO code ( 7https://github.com/ghc-proposals/ghc-proposals/pull/3301but no stack trace can be produced at the moment!).Throws opaque Exception: if ErrorExample:expectIOError "something bad happened" $ Left (newError "oh no!")-*** Exception: something bad happened: oh no! Important:  itself does not implement , to discourage the exception workflow. The  thrown is private to this module and thus can@t be @caught@ in a typed manner. If you use this function, you either have to catch :, or it will bubble up and lead to your program crashing. error Catch any s thrown by an IO a as Either Error a..The IOException is converted to an error with ', and the given message is added with . This prevents the common pattern of bubbling up exceptions without any context.ifIOError "could not open file" (Control.Exception.throwIO (userError "oh noes!"))>= unwrapIOError9*** Exception: could not open file: user error (oh noes!) error Catch any s thrown by an IO a as Either Error a..The IOException is converted to an error with ', and the given message is added with . This prevents the common pattern of bubbling up exceptions without any context.Use TypeApplications to specify the  you want to catch.:set -XTypeApplicationsifError @Exc.ArithException "arithmetic exception" (putStr $ show $ 1 Data.Ratio.% 0)Left (Error ["arithmetic exception","Ratio has zero denominator"])%It can then be handled like a normal .)The function lends itself to piping with :(putStr $ show $ 1 Data.Ratio.% 0) & ifError @Exc.ArithException "arithmetic exception"Left (Error ["arithmetic exception","Ratio has zero denominator"])Bear in mind that pure exceptions are only raised when the resulting code is forced (thus the putStrLn $ show in the above example). error.Show the pretty printed string without quotes.errorThe 8 instance exists for the user@s convenience on the REPL.%If you want to display an error, use  instead.          !"#$%&$error-0.2.1.2-3VRq5HweXFaBznpcqrt51j Data.ErrorErrornewError showToErrorexceptionToError addContext prettyError unwrapError expectError unwrapIOError expectIOError ifIOErrorifError$fExceptionErrorException$fShowErrorException $fShowErrorbaseGHC.ShowShowGHC.Exception.Type ExceptionshowGHC.BaseStringdisplayException Data.EitherLeftGHC.ErrerrorGHC.IOthrowIOEither SomeExceptionGHC.IO.Exception IOException Data.Function&