[Haskell-cafe] Re: Optimizing 'sequence'

Luke Palmer lrpalmer at gmail.com
Tue Jul 22 04:17:04 EDT 2008


On Tue, Jul 22, 2008 at 1:15 AM, Gracjan Polak <gracjanpolak at gmail.com> wrote:
> Antoine Latter <aslatter <at> gmail.com> writes:
>>
>> The function "runIdentity" is found in Control.Monad.Identity in the
>> mtl package.
>>
> But still... Identity is a bit special monad. What other monads need full
> laziness in sequence? As far as I know IO is strict. What about lazy/strict
> state monad?

A little formal reasoning reveals that sequence1 = sequence2 exactly
when (>>=) is strict in its left argument.  There are four common
monads which are _not_: Identity, Reader, Writer, State (and RWS by
extension).

Luke


More information about the Haskell-Cafe mailing list