[Haskell-cafe] Re: Monads aren't evil? I think they are.
ChrisK
haskell at list.mightyreason.com
Tue Jan 13 05:16:32 EST 2009
Henning Thielemann 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.
I completely disagree with that example.
The Put monad is, mainly, a specialized State monad.
The internal state being the current fixed-size bytestring memory buffer that
has been allocated and is being filled.
The monad make the execution sequential so that there is only one memory buffer
being filled at a time.
In Put, when one memory buffer has been filled it allocates the next one to
create a Lazy Bytestring.
This is not to say that all M () are really monads, but just that Put () is.
--
Chris
More information about the Haskell-Cafe
mailing list