
13 Jan
2009
13 Jan
'09
7:55 p.m.
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.