a monadic if or case?
Kevin Millikin
kmillikin@atcorp.com
Thu, 13 Feb 2003 08:45:47 -0600
On Thursday, February 13, 2003 8:33 AM, Arjan van IJzendoorn
[SMTP:afie@cs.uu.nl] wrote:
> Not with the syntactic sugar of 'if'.
> But you can write [warning: untested code ahead]
>
> ifM :: IO Bool -> IO a -> IO a -> IO a
> ifM test yes no = do
> b <- test
> if b then yes else no
I had
ifM :: Monad m => m Bool -> m a -> m a -> m a
ifM tst thn els =
do b <- tst
if b then thn else els
And I just tested it.
----
Kevin S. Millikin Architecture Technology Corporation
Research Scientist Specialists in Computer Architecture
kmillikin@atcorp.com http://www.atcorp.com