When a value is bound in do-notation, the pattern on the left
hand side of <- might not match. In this case, this class
provides a function to recover.
A Monad without a MonadFail instance may only be used in conjunction
with pattern that always match, such as newtypes, tuples, data types with
only a single data constructor, and irrefutable patterns (~pat).
Instances of MonadFail should satisfy the following law: fail s should
be a left zero for Control.Monad.>>=,
fail s >>= f = fail s
If your Monad is also Control.Monad.MonadPlus, a popular definition is
fail _ = mzero
fail s should be an action that runs in the monad itself, not an
exception (except in instances of MonadIO). In particular,
fail should not be implemented in terms of error.
Methods
fail :: HasCallStack => String -> m a
Instances8MonadFail, …
MonadFail MaybeDefined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.FailMonadFail QDefined in ghc-internal-10.0.0 · GHC.Internal.TH.MonadMonadFail PDefined in ghc-internal-10.0.0 · GHC.Internal.Text.ParserCombinators.ReadPMonadFail ReadPDefined in ghc-internal-10.0.0 · GHC.Internal.Text.ParserCombinators.ReadPMonadFail ReadPrecDefined in ghc-internal-10.0.0 · GHC.Internal.Text.ParserCombinators.ReadPrecMonadFail IODefined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.FailMonadFail []Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.FailMonadFail f => MonadFail (Ap f)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Monoid