Fwd: transformers versus mtl

(Ganesh, sorry for the double post, I meant to send this to the list)
Hello,
On Tue, Mar 24, 2009 at 2:42 PM, Sittampalam, Ganesh
Sittampalam, Ganesh wrote: ...the Functor instances for ReaderT r m and WriterT w m now (correctly) depend on Functor m, whereas in mtl they depend on Monad m.
Does anyone ever use ReaderT and WriterT with a type that is not a monad (i.e., use them as functor transformers rather then monad transformers)? On the other hand, with the unfortunate lack of relation between Functor and Monad in Haskell, it seems these instances will not work if I try to transform a monad that does not have a functor instance. -Iavor

On Tue, Mar 24, 2009 at 04:14:38PM -0700, Iavor Diatchki wrote:
On Tue, Mar 24, 2009 at 2:42 PM, Sittampalam, Ganesh
wrote: Sittampalam, Ganesh wrote: ...the Functor instances for ReaderT r m and WriterT w m now (correctly) depend on Functor m, whereas in mtl they depend on Monad m.
Does anyone ever use ReaderT and WriterT with a type that is not a monad (i.e., use them as functor transformers rather then monad transformers)? On the other hand, with the unfortunate lack of relation between Functor and Monad in Haskell, it seems these instances will not work if I try to transform a monad that does not have a functor instance.
It's more that they're used polymorphically, and the constraint Monad m is now insufficient: Functor m is also needed.

Iavor Diatchki wrote:
On Tue, Mar 24, 2009 at 2:42 PM, Sittampalam, Ganesh
wrote: Sittampalam, Ganesh wrote: ...the Functor instances for ReaderT r m and WriterT w m now (correctly) depend on Functor m, whereas in mtl they depend on Monad m.
...?On the other hand, with the unfortunate lack of relation between Functor and Monad in Haskell, it seems these instances will not work if I try to transform a monad that does not have a functor instance.
well, if base monad `m` is not a Functor, then it seems decidedly odd to me for the transformed monad to become a Functor... the transformer would be doing more than you'd expect! But if you don't use (Functor (ReaderT r m)), only (Monad (ReaderT r m)), perhaps it works as well as could be expected? (Or maybe it doesn't work after all; then my logic here is useless) -Isaac

On Tue, Mar 24, 2009 at 4:39 PM, Isaac Dupree
Iavor Diatchki wrote:
On Tue, Mar 24, 2009 at 2:42 PM, Sittampalam, Ganesh
wrote: Sittampalam, Ganesh wrote: ...the Functor instances for ReaderT r m and WriterT w m now (correctly) depend on Functor m, whereas in mtl they depend on Monad m.
...?On the other hand, with the unfortunate lack of relation between Functor and Monad in Haskell, it seems these instances will not work if I try to transform a monad that does not have a functor instance.
well, if base monad `m` is not a Functor, then it seems decidedly odd to me for the transformed monad to become a Functor... the transformer would be doing more than you'd expect! But if you don't use (Functor (ReaderT r m)), only (Monad (ReaderT r m)), perhaps it works as well as could be expected? (Or maybe it doesn't work after all; then my logic here is useless)
-Isaac
I'm pretty sure all monads are functors. Alex

On 2009 Mar 24, at 20:36, Alexander Dunlap wrote:
I'm pretty sure all monads are functors.
All monads are functors, but IIRC not all Monads are Functors. But Monad includes a liftM which is the same as Functor's fmap (usually? something tickling me about possibly the list Monad?) so in fact you *could* synthesize a Functor from atop a Monad that isn't already a Functor. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
participants (5)
-
Alexander Dunlap
-
Brandon S. Allbery KF8NH
-
Iavor Diatchki
-
Isaac Dupree
-
Ross Paterson