@@ -7,7 +7,6 @@ module Effectful.Error.Dynamic
9import Data.Typeable
9import Data.Typeable
12import Effectful.Handler
11import Effectful.Handler
13import Effectful.Monad
12import Effectful.Monad
@@ -15,12 +14,12 @@ import qualified Effectful.Error as E
16data Error e :: Effect where
15data Error e :: Effect where
17 ThrowError :: e -> Error e m a
16 ThrowError :: e -> Error e m a
18− CatchError :: m a -> (CallStack -> e -> m a) -> Error e m a
17+ CatchError :: m a -> (E.CallStack -> e -> m a) -> Error e m a
21 :: Typeable e
20 :: Typeable e
22 => Eff (Error e : es) a
21 => Eff (Error e : es) a
23− -> Eff es (Either (CallStack, e) a)
22+ -> Eff es (Either (E.CallStack, e) a)
24runError = reinterpretM E.runError $ \env -> \case
23runError = reinterpretM E.runError $ \env -> \case
25 ThrowError e -> E.throwError e
24 ThrowError e -> E.throwError e
26 CatchError m h -> localSeqUnlift env $ \unlift -> do
25 CatchError m h -> localSeqUnlift env $ \unlift -> do
@@ -33,14 +32,14 @@ throwError
33throwError = send . ThrowError
32throwError = send . ThrowError
36− :: Error e :> es
35+ :: (HasCallStack, Error e :> es)
37 => Eff es a
36 => Eff es a
38− -> (CallStack -> e -> Eff es a)
37+ -> (E.CallStack -> e -> Eff es a)
39 -> Eff es a
38 -> Eff es a
40catchError m = send . CatchError m
39catchError m = send . CatchError m
43− :: Error e :> es
42+ :: (HasCallStack, Error e :> es)
44 => Eff es a
43 => Eff es a
45− -> Eff es (Either (CallStack, e) a)
44+ -> Eff es (Either (E.CallStack, e) a)
46tryError m = (Right <$> m) `catchError` \es e -> pure $ Left (es, e)
45tryError m = (Right <$> m) `catchError` \es e -> pure $ Left (es, e)