Re: [Haskell-cafe] MonadTrans lift implementation

2009-01-20 Thread Mauro J. Jaskelioff
Ross Paterson wrote: > On Mon, Jan 19, 2009 at 01:13:37PM -0800, Jonathan Cast wrote: > >> (On the other hand, your hunch that lift = return is correct --- so you >> get a cookie for that; it's just that return here is neither the return >> of the monad for m nor the return of the monad for Read

Re: [Haskell-cafe] MonadTrans lift implementation

2009-01-19 Thread ajb
G'day all. Quoting Jonathan Cast : (By the way, you *do* have the equations lift (return x) = return x [...] Right. And you could, at least in principle, implement "return" this way in all monad transformers. Cheers, Andrew Bromage ___ Haskel

Re: [Haskell-cafe] MonadTrans lift implementation

2009-01-19 Thread Jonathan Cast
On Mon, 2009-01-19 at 21:31 +, Ross Paterson wrote: > On Mon, Jan 19, 2009 at 01:13:37PM -0800, Jonathan Cast wrote: > > (On the other hand, your hunch that lift = return is correct --- so you > > get a cookie for that; it's just that return here is neither the return > > of the monad for m nor

Re: [Haskell-cafe] MonadTrans lift implementation

2009-01-19 Thread Ross Paterson
On Mon, Jan 19, 2009 at 01:13:37PM -0800, Jonathan Cast wrote: > (On the other hand, your hunch that lift = return is correct --- so you > get a cookie for that; it's just that return here is neither the return > of the monad for m nor the return of the monad for ReaderT m. It is, > instead, the r

Re: [Haskell-cafe] MonadTrans lift implementation

2009-01-19 Thread Jonathan Cast
On Mon, 2009-01-19 at 13:03 -0800, Daryoush Mehrtash wrote: > Is there a reason why the lift function in ReaderT's MonadTrans instance is > implemented as: > > instance MonadTrans (ReaderT r) where > > lift m = ReaderT $ \_ -> m > > > > Instead of just using the monad's return function?

Re: [Haskell-cafe] MonadTrans lift implementation

2009-01-19 Thread Brent Yorgey
On Mon, Jan 19, 2009 at 01:03:55PM -0800, Daryoush Mehrtash wrote: > lift m = ReaderT $ \_ -> m > return a = ReaderT $ \_ -> return a If you look carefully you will see that these are not the same. -Brent ___ Haskell-Cafe mailing list Haskell

[Haskell-cafe] MonadTrans lift implementation

2009-01-19 Thread Daryoush Mehrtash
Is there a reason why the lift function in ReaderT's MonadTrans instance is implemented as: instance MonadTrans (ReaderT r) where lift m = ReaderT $ \_ -> m Instead of just using the monad's return function? Could "lift m" be implemented as "return m"? instance (Monad m) => Monad (Rea