looking for data structure advice

David Roundy droundy at abridgegame.org
Mon Dec 15 07:05:01 EST 2003


On Mon, Dec 15, 2003 at 08:55:10AM +0000, Graham Klyne wrote:
> I apologize... my question was unclear.
> 
> It was not the standard MonadPlus class and functions that I was asking 
> about, but the specific instance for Maybe (i.e. or_maybe).  As it happens, 
> a couple of times in the past couple of weeks, I might have used such a 
> function if it were available in the standard libraries.

My or_maybe is just defined as

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

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

f = a `or_maybe` b `or_maybe` c
-- 
David Roundy
http://www.abridgegame.org


More information about the Haskell-Cafe mailing list