On Dec 14, 2011, at 4:40 PM, Ivan Lazar Miljenovic wrote:
[...] Apart from some
basic combinators in Control.Monad or the definitions of monad
transformers, how much of what you write in do-blocks is applicable to
some generic Monad instance as opposed to a specific Monad?
Well, if my *only* constraint on a type is that it be an instance of Monad, then *all* of the code written in do-blocks will be applicable to a generic Monad instance. That's the whole point. :-)
Furthermore, you make it sound like this generic case scenario is incredibly rare, but in fact it is very common: it occurs whenever someone writes a monadic transformer, which happens all the time. Imagine what writing monadic transformers would be like if you couldn't always trust that, say, (>>=) was a well-defined operation?
Cheers,
Greg