looking for data structure advice

Graham Klyne GK at ninebynine.org
Tue Dec 16 00:18:16 EST 2003


At 07:05 15/12/03 -0500, David Roundy wrote:
>My or_maybe is just defined as
>
>or_maybe (Just e) _ = Just e
>or_maybe Nothing f = f
>
>which is pretty simple...

Indeed... I have been tending to do something similar inline...

I'm finding there's a tension between having lots of auxilliary functions 
and duplicated inline logic when it comes to code readability.  If a 
(simple) function is available from a standard library, that tebds (in my 
mind) to suggest using the function provided, as that represents a 
recognized idiom.

At 13:21 15/12/03 +0100, Samuel Tardieu wrote:
>I think there has been some misunderstanding here.
>
>What the other posters wrote is that it is definitely available, but
>under the "mplus" name.

Aha?   I looked for a MonadPlus instance of Maybe in the prelude, and 
didn't see it defined there.  Is it defined in one of the standard 
libraries?   Ah, now I see it is...  I'm almost used to looking to the 
Control.Monad.<foo> libraries, I didn't think to check Control.Monad.  Oops.

One day, I'll learn to look in all the right places.

#g


------------
Graham Klyne
For email:
http://www.ninebynine.org/#Contact



More information about the Haskell-Cafe mailing list