polysemy- Higher-order, low-boilerplate, zero-cost free monads.

Safe HaskellNone





data Error e m a where Source #


Throw :: e -> Error e m a 
Catch :: forall e m a. m a -> (e -> m a) -> Error e m a 
type DefiningModule (Error :: Type -> (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Polysemy.Error

type DefiningModule (Error :: Type -> (k -> Type) -> k -> Type) = "Polysemy.Error"


throw :: forall e r a. MemberWithError (Error e) r => e -> Sem r a Source #

catch :: forall e r a. MemberWithError (Error e) r => Sem r a -> (e -> Sem r a) -> Sem r a Source #

fromEither :: Member (Error e) r => Either e a -> Sem r a Source #

Upgrade an Either into an Error effect.


fromEitherM :: forall e m r a. (Member (Error e) r, Member (Lift m) r) => m (Either e a) -> Sem r a Source #

A combinator doing sendM and fromEither at the same time. Useful for interoperating with IO.



runError :: Sem (Error e ': r) a -> Sem r (Either e a) Source #

Run an Error effect in the style of ExceptT.

runErrorAsAnother :: forall e1 e2 r a. Member (Error e2) r => (e1 -> e2) -> Sem (Error e1 ': r) a -> Sem r a Source #

Transform one Error into another. This function can be used to aggregate multiple errors into a single type.


runErrorInIO Source #


:: (Typeable e, Member (Lift IO) r) 
=> (forall x. Sem r x -> IO x)

Strategy for lowering a Sem action down to IO. This is likely some combination of runM and other interpters composed via .@.

-> Sem (Error e ': r) a 
-> Sem r (Either e a) 

Run an Error effect as an IO Exception. This interpretation is significantly faster than runError, at the cost of being less flexible.