On Tue, Jan 13, 2009 at 5:19 PM, Dan Doel <span dir="ltr"><<a href="mailto:dan.doel@gmail.com">dan.doel@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">On Tuesday 13 January 2009 5:51:09 pm Luke Palmer wrote:<br>
> On Tue, Jan 13, 2009 at 11:21 AM, Tim Newsham <<a href="mailto:newsham@lava.net">newsham@lava.net</a>> wrote:<br>
> > I have seen several libraries where all functions of a monad have the<br>
> ><br>
> >> monadic result (), e.g. Binary.Put and other writing functions. This is<br>
> >> a clear indicator, that the Monad instance is artificial and was only<br>
> >> chosen because of the 'do' notation.<br>
> ><br>
> > Maybe that was the initial reason, but I've actually found the<br>
> > Binary.Put.PutM (where Put = PutM ()) to be useful. Sometimes<br>
> > your putter does need to propogate a result...<br>
><br>
> But that's the whole point of Writer! Take a monoid, make it into a monad.<br>
> Put as a monad is silly.<br>
<br>
</div></div>You mean it should be Writer instead?</blockquote><div><br>Or rather, PutM should not exist (or be exposed), and Put should just be a monoid.<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
When GHC starts optimizing (Writer Builder) as well as it optimizes PutM, then<br>
that will be a cogent argument. Until then, one might argue that it misses<br>
"the whole point of Put".</blockquote><div><br>Well it can still serve as an optimization over bytestrings using whatever trickery it uses (I am assuming here -- I am not familiar with its trickery), the same way DList is an optimization over List. It's just that its monadiness is superfluous.<br>
<br>Surely PutM and Writer Put have almost the same performance?! (I am worried if not -- if not, can you give an indication why?)<br><br>Luke</div></div>