polysemy-1.9.0.0: Higher-order, low-boilerplate free monads.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Polysemy.Fail

Description

 
Synopsis

Effect

newtype Fail m a Source #

This effect abstracts the concept of MonadFail, which is a built-in mechanism that converts pattern matching errors to calls to the current monad's instance of that class.

The instance defined in Polysemy.Internal uses this effect to catch those errors.

Constructors

Fail String 

Interpretations

runFail :: Sem (Fail ': r) a -> Sem r (Either String a) Source #

Run a Fail effect purely.

failToError :: Member (Error e) r => (String -> e) -> Sem (Fail ': r) a -> Sem r a Source #

Transform a Fail effect into an Error e effect, through providing a function for transforming any failure to an exception.

failToNonDet :: Member NonDet r => Sem (Fail ': r) a -> Sem r a Source #

Transform a Fail effect into a NonDet effect, through mapping any failure to empty.

failToEmbed :: forall m r a. (Member (Embed m) r, MonadFail m) => Sem (Fail ': r) a -> Sem r a Source #

Run a Fail effect in terms of an underlying MonadFail instance.