mtl: Context of execWriterT
Daniel Díaz
danieldiaz at asofilak.es
Thu Apr 14 14:25:39 CEST 2011
Hi,
I have a question about the context of the execWriterT function, in
Control.Monad.Writer of the mtl package. The current context forces the
containter type to be a Monad, while is enough a Functor. Yes, WriterT
is a monad transformer, so this is not a problem, but I have as a law to
write the less restrictive context for every function.
So, is there any reason to do this context more restrictive?
If not, the obvious way to do it may be:
execWriterT :: Functor m => WriterT w m a -> m w
execWriterT = fmap snd . runWriterT
However, I thought that there must be a reason explaining this fact.
More information about the Libraries
mailing list