fail package:rio
failing lets you chain traversals together; if the 1st
traversal fails, the 2nd traversal will be used.
>>> ([1,2],[3]) & failing (_1.each) (_2.each) .~ 0
([0,0],[3])
>>> ([],[3]) & failing (_1.each) (_2.each) .~ 0
([],[0])
Note that the resulting traversal won't be valid unless either both
traversals don't touch each others' elements, or both traversals
return exactly the same results. To see an example of how
failing can generate invalid traversals, see
this
Stackoverflow question.
indicates program failure with an exit code. The exact interpretation
of the code is operating-system dependent. In particular, some values
may be prohibited (e.g. 0 on a POSIX-compliant system).
Lifted version of "System.Exit.exitFailure".
@since 0.1.9.0.
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
>>=,
fail s >>= f = fail s
If your
Monad is also
MonadPlus, a popular definition is
fail _ = mzero