Monad Maybe?

Ken Shan
Sat, 21 Sep 2002 18:37:53 -0400

Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On 2002-09-21T12:56:13-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

How about something like:

    msum [ liftM show (number g)
	 , liftM show (fraction g)
	 , liftM (("*"++).show) (nimber g) ]

Edit this signature at
So the choice which Lomborg presents us with, of whether to save a drowning
Tuvaluan (climate change) or a dying Somalian (water and sanitation) is not=
a choice at all -- in fact we need to do both, and not least because one is
unlikely to be successful without the other.

Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.0.7 (GNU/Linux)