[Haskell-cafe] ANN: Control.Monad.IfElse

Joachim Breitner mail at joachim-breitner.de
Wed Dec 24 20:17:08 EST 2008


Am Montag, den 22.12.2008, 09:24 -0500 schrieb Jeff Heard:
> Provides useful anaphoric and monadic versions of if-else and when, as
> well as infix operators for the actions to allow things like this:

nice package. Especially 

awhen :: Monad m => Maybe a -> (a -> m ()) -> m ()

is something I define in almost every project.

Note that the documentation:
Chainable anaphoric when. Takes a maybe value. 

if the value is Just x then execute action x , then return True .
otherwise return False .
does not match the implementation.

And looking at the code, you could, you want, build your more special
functions upon your more general ones, e.g.:

awhen mb action = aif mb action (return ())


Joachim "nomeata" Breitner
  mail: mail at joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C
  JID: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/
  Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081225/1d65908b/attachment.bin

More information about the Haskell-Cafe mailing list