Monad Maybe?
Andrew J Bromage
ajb@spamcop.net
Sun, 22 Sep 2002 13:30:43 +1000
G'day all.
On Sat, Sep 21, 2002 at 12:56:13PM -0700, Russell O'Connor wrote:
> case (number g) of
> Just n -> Just (show n)
> Nothing ->
> case (fraction g) of
> Just n -> Just (show n)
> Nothing ->
> case (nimber g) of
> Just n -> Just ("*"++(show n))
> Nothing -> Nothing
This isn't exactly the most beautiful way of doing it, but...
(number g >>= return . show) `mplus`
(fraction g >>= return . show) `mplus`
(nimber g >>= return . ('*':) . show)
Cheers,
Andrew Bromage