| Copyright | (C) 2015 David Luposchainsky (C) 2015 Herbert Valerio Riedel |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | libraries@haskell.org |
| Stability | provisional |
| Portability | portable |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
Control.Monad.Fail
Description
Transitional module providing theMonadFail class and primitive instances.
This module can be imported for defining forward compatibleMonadFail instances:
import qualified Control.Monad.Fail as Failinstance Monad Foo where (>>=) = {- ...bind impl... -} -- Provide legacyfail implementation for when -- new-style MonadFail desugaring is not enabled. fail = Fail.failinstance Fail.MonadFail Foo where fail = {- ...fail implementation... -}Seehttps://prime.haskell.org/wiki/Libraries/Proposals/MonadFail for more details.
Since: 4.9.0.0
classMonad m =>MonadFail mwhereSource#
When a value is bound indo-notation, the pattern on the left hand side of<- might not match. In this case, this class provides a function to recover.
AMonad without aMonadFail 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 ofMonadFail should satisfy the following law:fail s should be a left zero for>>=,
fail s >>= f = fail s
If yourMonad is alsoMonadPlus, a popular definition is
fail _ = mzero
Since: 4.9.0.0
| MonadFail []Source# | Since: 4.9.0.0 |
| MonadFailMaybeSource# | Since: 4.9.0.0 |
| MonadFailIOSource# | Since: 4.9.0.0 |
| MonadFailReadPSource# | Since: 4.9.0.0 |
| MonadFailReadPrecSource# | Since: 4.9.0.0 |
| MonadFail (ST s)Source# | Since: 4.11.0.0 |
| MonadFail (ST s)Source# | Since: 4.10 |
| MonadFail f =>MonadFail (Ap f)Source# | Since: 4.12.0.0 |
Produced byHaddock version 2.20.0