| Copyright | (c) Aaron Friel |
|---|---|
| License | BSD-3 |
| Maintainer | Aaron Friel <mayreply@aaronfriel.com> |
| Stability | unstable |
| Portability | portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Control.MonadFail.Graph
Description
This is only used in Do Notation with refutable patterns. e.g.:
do Just a <- m
k a
Is desugared as:
let f (Just a) = k a
f _ = fail "Pattern match failure in do expression..."
in m >>= k
With -XApplicativeDo, there are two outstanding issues:
First, This will not compile (https:/ghc.haskell.orgtracghcticket/13648) as
the body statements m1 and m2 are desugared incorrectly:
f m1 m2 k = do
m1
m2
k
To resolve, replace m1 with _ <- m1.
Second, must be in scope (https:/ghc.haskell.orgtracghcticket/13649)
when wildcard patterns are used. The module Prelude.Graphted takes care of
this, and custom preludes must as well. A fail constraint will not
be added unless a refutable pattern is used.GMonadFail
- class GMonad m => GMonadFail m where
- type Fail m :: p
Documentation
class GMonad m => GMonadFail m where Source #
Graph indexed monad with failure.
Associated Types
The unit failure element of the index.
Default instance: Fail m = Unit m
Methods
gfail :: String -> m (Fail m) a Source #
Fail with a message.
Default implementation requires the default instance of Fail.
gfail :: (GMonadZero m, Zero m ~ Fail m) => String -> m (Fail m) a Source #
Fail with a message.
Default implementation requires the default instance of Fail.
Instances
| Monad m => GMonadFail * (GWrapped m) Source # | |
| IxMonadZero * m => GMonadFail (*, *) (WrappedIx m) Source # | |