[Haskell-cafe] Robert Harper on monads and laziness

Manuel M T Chakravarty chak at cse.unsw.edu.au
Wed May 4 01:57:43 CEST 2011


I completely agree that laziness enables a number of nice coding idioms and, as Lennart described so eloquently, it does facilitate a combinator-based coding style among other things:

  http://augustss.blogspot.com/2011/05/more-points-for-lazy-evaluation-in.html

(Note that even Bob admits that this is an advantage.)

What I meant is that if asked what is more important about Haskell, its laziness or purity, I think most people would pick purity.  (But then it's a strange decision to make as laziness implies a need for purity as discussed.)

Manuel

Jan-Willem Maessen:
> 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.
> 
> -Jan-Willem Maessen




More information about the Haskell-Cafe mailing list