Re: Monad Maybe?

2002-09-24 Thread Alastair Reid
Hal Daume [EMAIL PROTECTED] writes: I know this has been written about way too much, but I was wondering what people thought about using 'liftM f' as opposed to '= return . f'. I would probably have written Andrew's code using liftM, but I don't know if one is necessarily better than the

Re: Monad Maybe?

2002-09-23 Thread Hal Daume III
I know this has been written about way too much, but I was wondering what people thought about using 'liftM f' as opposed to '= return . f'. I would probably have written Andrew's code using liftM, but I don't know if one is necessarily better than the other. Does anyone have strong thoughts on

Re: Monad Maybe?

2002-09-23 Thread Iavor Diatchki
hi, i personally think that one should use fmap instead. it tells you exactly how much structure you need. having said that it is sometimes annoying to get the extra Functor constraint (alas Functor is not a super class of Moand)... so my preference is: 1. fmap 2. liftM 3. bind with return

Monad Maybe?

2002-09-21 Thread Russell O'Connor
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 [To: [EMAIL PROTECTED]] Is there a nicer way of writing the following sort of code? 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

Re: Monad Maybe?

2002-09-21 Thread Dylan Thurston
On Sat, Sep 21, 2002 at 12:56:13PM -0700, Russell O'Connor wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 [To: [EMAIL PROTECTED]] Is there a nicer way of writing the following sort of code? case (number g) of Just n - Just (show n) Nothing - case (fraction g) of Just n

Re: Monad Maybe?

2002-09-21 Thread Pixel
Russell O'Connor [EMAIL PROTECTED] writes: [To: [EMAIL PROTECTED]] Is there a nicer way of writing the following sort of code? 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 -

Re: Monad Maybe?

2002-09-21 Thread Ken Shan
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 [

Re: Monad Maybe?

2002-09-21 Thread Hal Daume III
show g | Just n = number g = Just (show n) | Just n = fraction g = Just (show n) | Just n = nimber g = Just (*++show n) | Nothing = Nothing These should be Just n - number g, not = - Hal ___ Haskell-Cafe