on master help sign in
Add Errors helper
c76e1f7Andrzej Rybczak
src/Effectful/Error.hs+7
@@ -18,6 +18,7 @@
18-}
18-}
19module Effectful.Error
19module Effectful.Error
20 ( Error
20 ( Error
21+ , Errors
21 , runError
22 , runError
22 , throwError
23 , throwError
23 , catchError
24 , catchError
@@ -28,6 +29,7 @@ module Effectful.Error
28 ) where
29 ) where
29
30
30import Control.Exception
31import Control.Exception
32+import Data.Kind
31import Data.Typeable
33import Data.Typeable
32import Data.Unique
34import Data.Unique
33import GHC.Stack
35import GHC.Stack
@@ -44,6 +46,11 @@ import Effectful.Internal.Monad
44data Error e :: Effect where
46data Error e :: Effect where
45 Error :: Unique -> Error e m r
47 Error :: Unique -> Error e m r
46
48
49+-- | Helper for multiple 'Error' effects.
50+type family Errors (errs :: [Type]) (es :: [Effect]) :: Constraint where
51+ Errors '[] es = ()
52+ Errors (err : errs) es = (Error err :> es, Errors errs es)
53+
47-- | TODO: write about possibility of an error escaping the scope of 'runError'
54-- | TODO: write about possibility of an error escaping the scope of 'runError'
48-- when misused with 'AsyncE'.
55-- when misused with 'AsyncE'.
49runError
56runError