Control.Monad.Writer.Strict not as strict as expected
matt at softmechanics.net
Fri Sep 16 01:50:02 CEST 2011
Thanks for the clarification. Though the lazy version suits my
present need well, I wonder if a variant strict in its monoid would be
useful as well. If nothing else, it might help highlight that the
Strict version is not, something I didn't realize until reading the
On Thu, Sep 15, 2011 at 2:02 PM, Edward Kmett <ekmett at gmail.com> wrote:
> On Thu, Sep 15, 2011 at 4:43 PM, Matt Brown <matt at softmechanics.net> wrote:
>> Hello all,
>> I've been debugging a space leak, and believe I've traced it to a
>> chain of unevaluated calls to mappend in the bind operator for
>> Control.Monad.Writer.Strict. I had expected these calls to be
>> evaluated strictly by the strict Writer, but it doesn't seem to be the
>> case. Am I understanding this correctly?
> The Strict in Control.Monad.Writer.Strict refers to the fact that the tuple
> is matched strictly -- not the Monoid.
>> If so, is this the intended
> The Strict/Lazy writer split has nothing to do with the strictness of your
> monoid, but rather whether or not operations such as:
>> fmap f ~(w, a) = (w, f a)
>> fmap f (w, a) = (w, f a)
> are used throughout the API. We default to Lazy because slightly more code
> can terminate (at least in the case of State), lthough some would challenge
> that due to the behavior in the presence of bottoms the Strict versions are
> more correct.
> Neither of these are, or are intended to be, the monad you are looking for.
> -Edward Kmett
More information about the Libraries