@@ -1,20 +1,23 @@
11{- | Support for checked exceptions.
22
3− The `Error` effect provided by this module is a suitable replacement for the
4− `Control.Monad.Except.ExceptT` monad transformer found in the mtl library.
5− It is __not__ intended to be a general mechanism for catching errors like
6− the functions of the 'exceptions' package. For example, if you want to catch
7− an unchecked exception like `Control.Exception.SomeException` or
8− `Control.Exception.ErrorCall` you could rely on `Control.Monad.catch`:
9−
10− >>> :{
11− let boom :: Eff '[IOE] String
12− boom = error "BOOM!"
13− in
14− runIOE $ boom `Control.Monad.Catch.catch` \(e :: ErrorCall) ->
15− return "caught some error"
16− :}
17− "caught some error"
3+The 'Error' effect provided by this module is a suitable replacement for the
4+'Control.Monad.Except.ExceptT' monad transformer found in the @mtl@ library. It
5+is __not__ intended to be a general mechanism for catching errors, that's what
6+the 'Except' effect is for.
7+
8+For example, if you want to catch an unchecked exception like
9+'Control.Exception.SomeException' or 'Control.Exception.ErrorCall' you could use
10+'Control.Monad.Catch.catch':
11+
12+>>> import qualified Control.Monad.Catch as E
13+>>> :{
14+ let boom :: Eff es String
15+ boom = error "BOOM!"
16+ in
17+ runIOE . runExcept $ boom `E.catch` \(e :: ErrorCall) -> pure "caught some error"
18+:}
19+"caught some error"
20+
1821-}
1922module Effectful.Error
2023 ( Error
@@ -35,11 +38,6 @@ import Effectful.Internal.Effect
3538import Effectful.Internal.Env
3639import Effectful.Internal.Monad
3740
38−-- $setup
39−-- >>> import Control.Monad.Catch
40−-- >>> import Control.Monad.IO.Class
41−-- >>> import Effectful.Interpreter
42−
4341data Error e :: Effect where
4442 Error :: Unique -> Error e m r
4543