Safe Haskell | Trustworthy |
---|
Exception-producing and exception-handling effects
- newtype Exc e v = Exc e
- type Fail = Exc ()
- throwExc :: (Typeable e, Member (Exc e) r) => e -> Eff r a
- die :: Member Fail r => Eff r a
- runExc :: Typeable e => Eff (Exc e :> r) a -> Eff r (Either e a)
- runFail :: Eff (Fail :> r) a -> Eff r (Maybe a)
- catchExc :: (Typeable e, Member (Exc e) r) => Eff r a -> (e -> Eff r a) -> Eff r a
- onFail :: Eff (Fail :> r) a -> Eff r a -> Eff r a
- rethrowExc :: (Typeable e, Typeable e', Member (Exc e') r) => (e -> e') -> Eff (Exc e :> r) a -> Eff r a
- liftEither :: (Typeable e, Member (Exc e) r) => Either e a -> Eff r a
- liftEitherM :: (Typeable1 m, Typeable e, Member (Exc e) r, SetMember Lift (Lift m) r) => m (Either e a) -> Eff r a
- liftMaybe :: Member Fail r => Maybe a -> Eff r a
- ignoreFail :: Eff (Fail :> r) a -> Eff r ()
Documentation
These are exceptions of the type e. This is akin to the error monad.
Exc e |
throwExc :: (Typeable e, Member (Exc e) r) => e -> Eff r aSource
Throw an exception in an effectful computation.
die :: Member Fail r => Eff r aSource
Makes an effect fail, preventing future effects from happening.
runExc :: Typeable e => Eff (Exc e :> r) a -> Eff r (Either e a)Source
Run a computation that might produce an exception.
catchExc :: (Typeable e, Member (Exc e) r) => Eff r a -> (e -> Eff r a) -> Eff r aSource
Run a computation that might produce exceptions, and give it a way to deal with the exceptions that come up.
:: Eff (Fail :> r) a | The fallible computation. |
-> Eff r a | The computation to run on failure. |
-> Eff r a |
Add a default value (i.e. failure handler) to a fallible computation. This hides the fact that a failure happened.
rethrowExc :: (Typeable e, Typeable e', Member (Exc e') r) => (e -> e') -> Eff (Exc e :> r) a -> Eff r aSource
Run a computation until it produces an exception, and convert and throw that exception in a new context.
liftEither :: (Typeable e, Member (Exc e) r) => Either e a -> Eff r aSource
Treat Lefts as exceptions and Rights as return values.
liftEitherM :: (Typeable1 m, Typeable e, Member (Exc e) r, SetMember Lift (Lift m) r) => m (Either e a) -> Eff r aSource
liftEither
in a lifted Monad