[Haskell-beginners] Re: Searching Maybe lists

aditya siram aditya.siram at gmail.com
Tue May 19 12:02:50 EDT 2009


>
>
>
> You will have to write  orMaybe  as
>
>   orMaybe Nothing  y = y
>   orMaybe x        _ = x
>
> though. (By the way, your original code for  orMaybe  doesn't seem to do
> what you want.) This function has already been implemented for you, it's
> called
>
>   mplus


My function 'orMaybe' takes two arguments m1 m2, if one of them is Nothing,
it returns Nothing, if m1 is Just , it returns m1, if m2 is Just, it returns
m2. This seems to be what I want. Why is this incorrect?

However, your function 'orMaybe' is much more concise and elegant.

thanks ...
-deech
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20090519/3d8e6f67/attachment.html


More information about the Beginners mailing list