>>>>> "David" == David Roundy <[EMAIL PROTECTED]> writes:

David> My or_maybe is just defined as

David> or_maybe (Just e) _ = Just e or_maybe Nothing f = f

David> which is pretty simple, so you can run a series of calculations
David> (assuming you want to keep the first that has a non-Nothing
David> result) using

David> f = a `or_maybe` b `or_maybe` c

The advantage of using "mplus" rather than "or_maybe" is that you can
write:

  f = a `mplus` b `mplus` c

and that it will also work with other MonadPlus instances. For
example, if you decide that you want to keep several results and work
with "[a]" rather than "Maybe a", your "f" function will work as-is
and will concatenate the different results.

While "Maybe a" holds zero or one value, "[a]" holds zero or more
values. Switching between both can something be very practical for
functions reuse.

  Sam
-- 
Samuel Tardieu -- [EMAIL PROTECTED] -- http://www.rfc1149.net/sam

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to