[Haskell-cafe] Re: Is my code too complicated?

Ertugrul Soeylemez es at ertes.de
Mon Jul 5 09:41:21 EDT 2010

Stephen Tetley <stephen.tetley at gmail.com> wrote:

> On 5 July 2010 11:30, Ertugrul Soeylemez <es at ertes.de> wrote:
> > That's what monad transformers are good for.  Why reinvent the
> > wheel?
> The post was chiming in with Felipe Lessa's comment upthread that
> avoiding transfomers can have performance benefits.
> Whether the formulation I gave is particulary efficient is moot - I'd
> have to give consideration to the strictness of the state at least -
> but I was answering Yves Parès about "how" you would do it, rather
> than "why".

Yes, there is some performance loss because of wrapping/unwrapping, but
I think this loss is neglible for most applications.  And I'd ask
anyway.  This is a discussion thread after all. =)

> Given the status of MTL, I nowadays avoid transformers for pragmatic
> reasons rather than performance ones. If I have substantial code I'll
> rely on Iavor S. Diatchki's very nice MonadLib, but for small projects
> I'll just roll an amalgamated monad.

Almost all of my projects, including one published one, depend on
monadLib.  I find the MTL comparatively inconvenient.

And especially for small projects I don't see why I should roll my own
monad.  I prefer to stick some transformers together.  For larger
applications my criterion is speed, but I've yet to see an application,
where transformers are too slow.


nightmare = unsafePerformIO (getWrongWife >>= sex)

More information about the Haskell-Cafe mailing list