MonadError and fundeps

Lauri Alanko la@iki.fi
Fri, 11 May 2001 01:07:52 +0300


On Thu, May 10, 2001 at 09:24:36PM +0000, Marcin 'Qrczak' Kowalczyk wrote:
> MonadReader, MonadWriter and MonadState classes have fundeps from the
> monad type to the environment / output / state type (I added them
> a few months ago).

Why? This makes composing and "subtyping" impossible:

instance (MonadTrans t, MonadState s m, Monad (t m)) 
	 => MonadState s (t m) where
    get = lift get
    put = lift . put

This is really useful, because you can thread multiple states (or read
multiple environments, or write multiple outputs, or whatnot), and
_directly_ use functions that operate on a particular state, without
having to do explicit lifting (to the correct level) all the time.

Fundeps add convenience, yes, but they restrict what you can do with the
monads. A bad tradeoff, IMHO.

Ah well, I'm kind of used to having to use customized versions of all
the common libs...


Lauri Alanko
la@iki.fi