on master help sign in
Documentation: Clarify that Error effect basically is ExceptT (#10)
26001d9Mann mit Hut
src/Effectful/Error.hs+23−1
@@ -1,4 +1,21 @@
1−-- | Support for checked exceptions.
1+{- | Support for checked exceptions.
2+
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"
18+-}
2module Effectful.Error
19module Effectful.Error
3 ( Error
20 ( Error
4 , runError
21 , runError
@@ -19,6 +36,11 @@ import Effectful.Internal.Effect
19import Effectful.Internal.Env
36import Effectful.Internal.Env
20import Effectful.Internal.Monad
37import Effectful.Internal.Monad
21
38
39+-- $setup
40+-- >>> import Control.Monad.Catch
41+-- >>> import Control.Monad.IO.Class
42+-- >>> import Effectful.Interpreter
43+
22data Error e :: Effect where
44data Error e :: Effect where
23 Error :: Unique -> Error e m r
45 Error :: Unique -> Error e m r
24
46