User login

Navigation

Monads = lazy, effect types = strict?

Wadler, for instance, makes the claim, in "The marriage of effects and monads" (pg. 1), that effects typing systems are usually found in strict languages, whereas monads are usually found in lazy languages. Why is this? Is there a technical reason, or just a difference in cultures between the two camps?

(I have seen others make an even stronger claim, that monads are especially suited for lazy languages, in some sense.)

Lazy languages have an additional issue with effects, namely sequencing. Monads solve this as well. Similarly, it's been common to do without that in strict languages and so effect systems are a closer fit to the way they've historically been used.

I've gone with monadic IO in interpreters for a few toy strict languages too, it's easy enough to implement and works fine. Admittedly I'm very much a haskell programmer these days, so it's my natural habitat as it were.

One of the effects is that the type structure of the language becomes considerably more intricate -- the distinction between values and computations becomes explicit in the types, and so you can distinguish between the type of integer values, the type of computations producing integers, and the type of thunked computations. The second pair of distinctions is not present in monadic semantics, and corresponds to the fact that cpbv decomposes the monad into a pair of adjoint functors whose composition is the monad. This end up giving you considerable control over things like the order of evaluation.