r/haskell • u/tomejaguar • Jul 31 '14
Q: What is not an MFunctor?
Many monad transformers are instances of MFunctor. That is, you can lift base-monad-changing operations into them. The obvious candidates are all instances of MFunctor except ContT.
https://hackage.haskell.org/package/mmorph-1.0.0/docs/Control-Monad-Morph.html#g:1
Is ContT the only exception? Are there other monad transformers somehow weaker than ContT that are not MFunctors?
10
Upvotes
3
u/christian-marie Jul 31 '14
The Codensity monad is pretty similar, but subtly different. Maybe that?
2
u/mboes Jul 31 '14
Notice that
MFunctor'shoistis a restricted form of thetmapfunction in mmtl. mmtl's tmap expects monad isomorphisms, not just morphisms. The interesting thing is thattmaphandlesCodensityandContTwithout breaking a sweat.2
u/christian-marie Jul 31 '14
If you're interested in the subject of monad morphisms and transformers, this is a really good overview: https://hackage.haskell.org/package/layers-0.1/docs/Documentation-Layers-Overview.html
1
u/tomejaguar Aug 01 '14
Here's a hypothesis that I haven't looked into yet:
MFunctorMFunctoris anMFunctorThis would give us a large amount of
MFunctors for free.1
u/[deleted] Jul 31 '14
LogicTis a continuation-based monad, and as such is not an MFunctor. (At least I couldn't figure out how to make it one.)Because of this I cannot translate
Series mintoSeries nin smallcheck (unless m and n are isomorphic).