[Haskell-cafe] Monads, do and strictness
Sebastian Fischer
fischer at nii.ac.jp
Sun Jan 22 15:49:50 CET 2012
On Sat, Jan 21, 2012 at 8:09 PM, David Barbour <dmbarbour at gmail.com> wrote:
> In any case, I think the monad identity concept messed up. The property:
> return x >>= f = f x
>
> Logically only has meaning when `=` applies to values in the domain.
> `undefined` is not a value in the domain.
>
> We can define monads - which meet monad laws - even in strict languages.
In strict languages both `return undefined >>= f` and `f undefined`
are observably equivalent to `undefined` so the law holds.
In a lazy language both sides might be observably different from
`undefined` but need to be consistently so. The point of equational
laws is that one can replace one side with the other without observing
a difference. Your implementation of `StrictT` violates this
principle.
Sebastian
More information about the Haskell-Cafe
mailing list