[Haskell-cafe] ANN: monad-bool 0.1

John Wiegley johnw at fpcomplete.com
Wed Jan 23 07:02:01 CET 2013

>>>>> Roman Cheplyaka <roma at ro-che.info> writes:

> - what do you need unsafeCoerce for?

Ok, after much discussion with edwardk and shachaf, I came to realize a few

 1. The functionality of my two monads 'AndM' and 'OrR' can be boiled down to
    two helper functions inside EitherT:

        returnIf :: Monad m => Bool -> e -> EitherT e m ()
        returnIf p a = if p then left a else right ()

        returnUnless :: Monad m => Bool -> e -> EitherT e m ()
        returnUnless p = returnIf (not p)

    These let you short-circuit monadic computations, returning the
    short-circuiting value as a Left; or as a Right if it reaches the end.

 2. The 'shortcircuit' library already provides short-circuiting variants of
    && and || that work just like Python's and Ruby's.  In fact, I think I'll
    talk to aristid about merging my Monoid definitions into that library.

Here are the updated docs:


I'll ask Ross Paterson to deprecate monad-bool.  And in future, I'll seek
review here first before uploading.

John Wiegley
FP Complete                         Haskell tools, training and consulting
http://fpcomplete.com               johnw on #haskell/irc.freenode.net

More information about the Haskell-Cafe mailing list