looking for data structure advice
Samuel Tardieu
sam at rfc1149.net
Mon Dec 15 13:21:09 EST 2003
>>>>> "Graham" == Graham Klyne <gk at ninebynine.org> writes:
Graham> I apologize... my question was unclear. It was not the
Graham> standard MonadPlus class and functions that I was asking
Graham> about, but the specific instance for Maybe (i.e. or_maybe).
Graham> As it happens, a couple of times in the past couple of weeks,
Graham> I might have used such a function if it were available in the
Graham> standard libraries.
I think there has been some misunderstanding here.
What the other posters wrote is that it is definitely available, but
under the "mplus" name.
If you want the "or_maybe" name, you can define it as:
or_maybe :: Maybe a -> Maybe a -> Maybe a
or_maybe = mplus
but you should rather use "mplus" where you would instead use
"or_maybe" because not only is "mplus" standard (you have to "import Monad"),
also it allows you to use something else than "Maybe" later if you
need to.
So, in short: the "or_maybe" you are looking for is already available,
but you should spell it "mplus".
Sam
--
Samuel Tardieu -- sam at rfc1149.net -- http://www.rfc1149.net/sam
More information about the Haskell-Cafe
mailing list