[Haskell-cafe] Improving MTL instances

wren ng thornton wren at freegeek.org
Wed Oct 15 18:55:41 EDT 2008


Henning Thielemann wrote:
>  I long thought that it is unnecessary use of type system extensions to
> require multi-parameter type classes for simple monads and its
> transformer versions. I thought it would be enough to have atomar monads
> like ST, IO and Identity, and monads like State, Reader, Writer,
> Continuation can be offered exclusively in the transforming variant.
> (State s a) would have to be defined as (StateT s Identity a) instead.
> This way MonadState, MonadReader and the other classes become
> unnecessary. However, 'lift' remains important with this design.

Doing it that way removes the polymorphism that MonadState, MonadReader, 
etc offer to clients. For example, the backwards-state monad[1] is a 
MonadState but not a StateT (without extra plumbing). There are other 
examples which don't even change the semantics. It seems a shame to 
force these implementations to give different names for "the same" 
functions. Are MPTCs onerous? They'll be in haskell-prime afterall. Of 
course, the fundeps are another matter entirely...

[1] 
http://luqui.org/blog/archives/2008/08/10/mindfuck-the-reverse-state-monad/

-- 
Live well,
~wren


More information about the Haskell-Cafe mailing list