[Haskell-cafe] Re: Monads aren't evil? I think they are.
Luke Palmer
lrpalmer at gmail.com
Tue Jan 13 19:27:10 EST 2009
On Tue, Jan 13, 2009 at 5:19 PM, Dan Doel <dan.doel at gmail.com> wrote:
> On Tuesday 13 January 2009 5:51:09 pm Luke Palmer wrote:
> > On Tue, Jan 13, 2009 at 11:21 AM, Tim Newsham <newsham at lava.net> wrote:
> > > I have seen several libraries where all functions of a monad have the
> > >
> > >> monadic result (), e.g. Binary.Put and other writing functions. This
> is
> > >> a clear indicator, that the Monad instance is artificial and was only
> > >> chosen because of the 'do' notation.
> > >
> > > Maybe that was the initial reason, but I've actually found the
> > > Binary.Put.PutM (where Put = PutM ()) to be useful. Sometimes
> > > your putter does need to propogate a result...
> >
> > But that's the whole point of Writer! Take a monoid, make it into a
> monad.
> > Put as a monad is silly.
>
> You mean it should be Writer instead?
Or rather, PutM should not exist (or be exposed), and Put should just be a
monoid.
> When GHC starts optimizing (Writer Builder) as well as it optimizes PutM,
> then
> that will be a cogent argument. Until then, one might argue that it misses
> "the whole point of Put".
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.
Surely PutM and Writer Put have almost the same performance?! (I am worried
if not -- if not, can you give an indication why?)
Luke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090113/54dcf707/attachment.htm
More information about the Haskell-Cafe
mailing list