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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe