Re: [Haskell-cafe] fmap vs. liftM

2008-02-06 Thread Henning Thielemann
On Tue, 5 Feb 2008, Felipe Lessa wrote: On Feb 5, 2008 6:06 PM, Dan Weston [EMAIL PROTECTED] wrote: Can you do this with a GHC rule? Something like: {-# RULES join_dot_fmap_return/id forall x . join (fmap return x) = x #-} Dan I guess this would make use of the rule

Re: [Haskell-cafe] fmap vs. liftM

2008-02-06 Thread Felipe Lessa
On Feb 6, 2008 11:50 AM, Henning Thielemann [EMAIL PROTECTED] wrote: That is, if the rule would be stated as above, then programmers _have_ to ensure that the law is satisfied, and the optimizer will penalize violations of the rules with non-working code. Be careful. For much less (blowing up

Re: [Haskell-cafe] fmap vs. liftM

2008-02-05 Thread Henning Thielemann
On Mon, 4 Feb 2008, Miguel Mitrofanov wrote: Problem is that from the idea Functor is a superclass of Monad, with the property that fmap == liftM. [cut] The second relation can even not be expressed in Haskell 98. Erm... class Functor f where fmap :: (a - b) - f a - f b

Re: [Haskell-cafe] fmap vs. liftM

2008-02-05 Thread Brandon S. Allbery KF8NH
On Feb 5, 2008, at 8:31 , Henning Thielemann wrote: How do you convince the compiler that 'join (fmap return x) == x' ? How do you convince it that the current formulation of Monad obeys the monad laws? (rhetorical) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL

Re: [Haskell-cafe] fmap vs. liftM

2008-02-05 Thread Henning Thielemann
On Tue, 5 Feb 2008, Brandon S. Allbery KF8NH wrote: On Feb 5, 2008, at 8:31 , Henning Thielemann wrote: How do you convince the compiler that 'join (fmap return x) == x' ? How do you convince it that the current formulation of Monad obeys the monad laws? (rhetorical) My point was

Re: [Haskell-cafe] fmap vs. liftM

2008-02-05 Thread Dan Weston
Can you do this with a GHC rule? Something like: {-# RULES join_dot_fmap_return/id forall x . join (fmap return x) = x #-} Dan Henning Thielemann wrote: On Tue, 5 Feb 2008, Brandon S. Allbery KF8NH wrote: On Feb 5, 2008, at 8:31 , Henning Thielemann wrote: How do you convince the

Re: [Haskell-cafe] fmap vs. liftM

2008-02-05 Thread Felipe Lessa
On Feb 5, 2008 6:06 PM, Dan Weston [EMAIL PROTECTED] wrote: Can you do this with a GHC rule? Something like: {-# RULES join_dot_fmap_return/id forall x . join (fmap return x) = x #-} Dan I guess this would make use of the rule (otherwise the transformation would change the code's

Re: [Haskell-cafe] fmap vs. liftM

2008-02-04 Thread Miguel Mitrofanov
Problem is that from the idea Functor is a superclass of Monad, with the property that fmap == liftM. [cut] The second relation can even not be expressed in Haskell 98. Erm... class Functor f where fmap :: (a - b) - f a - f b class Functor m = Monad m where return :: a - m a

Re: [Haskell-cafe] fmap vs. liftM

2008-02-04 Thread Derek Elkins
On Mon, 2008-02-04 at 12:22 -0200, Felipe Lessa wrote: Hi there, Reading http://www.haskell.org/haskellwiki/Things_to_avoid I found an interesting saying: By the way, in the case of IO monad the Functor class method fmap and the Monad based function liftM are the same. I always tought

Re: [Haskell-cafe] fmap vs. liftM

2008-02-04 Thread Henning Thielemann
On Mon, 4 Feb 2008, Felipe Lessa wrote: Hi there, Reading http://www.haskell.org/haskellwiki/Things_to_avoid I found an interesting saying: By the way, in the case of IO monad the Functor class method fmap and the Monad based function liftM are the same. I always tought that prop ::

[Haskell-cafe] fmap vs. liftM

2008-02-04 Thread Felipe Lessa
Hi there, Reading http://www.haskell.org/haskellwiki/Things_to_avoid I found an interesting saying: By the way, in the case of IO monad the Functor class method fmap and the Monad based function liftM are the same. I always tought that prop :: (Functor m, Monad m, Eq (m b)) = (a - b) - m a -

Re: [Haskell-cafe] fmap vs. liftM

2008-02-04 Thread Jonathan Cast
On 4 Feb 2008, at 6:22 AM, Felipe Lessa wrote: Hi there, Reading http://www.haskell.org/haskellwiki/Things_to_avoid I found an interesting saying: By the way, in the case of IO monad the Functor class method fmap and the Monad based function liftM are the same. I always tought that prop ::