[Haskell-cafe] Re: Monads aren't evil? I think they are.
Ross Paterson
ross at soi.city.ac.uk
Tue Jan 13 19:55:40 EST 2009
On Tue, Jan 13, 2009 at 07:44:17PM -0500, Dan Doel wrote:
> On Tuesday 13 January 2009 7:27:10 pm Luke Palmer wrote:
> > Surely PutM and Writer Put have almost the same performance?! (I am
> > worried if not -- if not, can you give an indication why?)
>
> The underlying monoid is Builder. The point of PutM is to be
> a version of Writer that's specialized to the Builder monoid for
> maximum performance. It looks like:
>
> data PairS a = PairS a {-# UNPACK #-} !Builder
>
> newtype PutM a = Put { unPut :: PairS a }
>
> I'm not sure why it's split up like that. Anyhow, the strict, unpacked
> Builder gets optimized better than Writer Builder.
But the only reason you want this monad optimized is so that you can
use it in do-notation. Otherwise you'd just use Builder directly.
More information about the Haskell-Cafe
mailing list