[Haskell-cafe] Robert Harper on monads and laziness
jmaessen at alum.mit.edu
Tue May 3 16:39:11 CEST 2011
On Tue, May 3, 2011 at 1:32 AM, Manuel M T Chakravarty
<chak at cse.unsw.edu.au> wrote:
>... Interestingly, today (at least the academic fraction of) the Haskell community appears to hold the purity of the language in higher regard than its laziness.
As someone who implemented Haskell with quite a bit less laziness, I'm
inclined to agree.
That said, I think it's easy to underestimate just how much of the
structure of the language really encourages a lazy evaluation
strategy. One example: where blocks scope over groups of conditional
RHSs. This is very handy, in that we can bind variables that are then
used in some, but not all, of the disjuncts. Grabbing the first
example that comes to hand from my own code:
tryOne (gg, uu) e
| not (consistent uu) = (gg', uu)
| uu==uu' = (gg, uu)
| otherwise = (gg', uu')
where gg' = gg `addEquation` e
uu' = uu `addEquation` e
This kind of thing happens all over the place in Haskell code -- it's
a very natural coding style -- but if you want to preserve purity it's
tough to compile without laziness.
More information about the Haskell-Cafe