[Haskell-cafe] Stupid question #852: Strict monad

David Menendez dave at zednenem.com
Thu Jan 1 17:03:29 EST 2009

On Thu, Jan 1, 2009 at 4:30 PM, Jonathan Cast <jonathanccast at fastmail.fm> wrote:
> On Thu, 2009-01-01 at 13:44 -0700, Luke Palmer wrote:
>> In my reply I missed the important consideration of the strictness of
>> (>>=), irrsepective of the values.  While you can not force values to
>> be strict in a monad without breaking a law, (>>=) is "up for grabs",
> Is it?  By the second monad law, (>>= return) is required to be strict.
> return must not be strict, as observed above.  Are there monads which
> satisfy both laws, but have undefined >>= f /= undefined, for some f?  I
> suspect (although I don't seem to have the source on my computer atm)
> that Control.Monad.State.{Lazy,Strict} both cheat on the second monad
> law anyway, though...

How about the Identity monad?

ghci> (return undefined :: Identity Char) `seq` ()
*** Exception: Prelude.undefined
ghci> runIdentity $ undefined >>= \_ -> return ()

"return" is strict and (>>=) is non-strict.
Dave Menendez <dave at zednenem.com>

More information about the Haskell-Cafe mailing list