[Haskell-cafe] Re[2]: strict Haskell dialect

Jan-Willem Maessen jmaessen at alum.mit.edu
Sat Feb 4 13:10:41 EST 2006


On Feb 3, 2006, at 8:16 PM, Brian Hulley wrote:

> Jan-Willem Maessen wrote:
>
>> I pointed out some problems with strict Haskell in a recent talk, but
>> I think it'd be worth underscoring them here in this forum.
>
> Is the text of this talk or points raised in it available online  
> anywhere?
>
>> <snip> There is one very difficult piece of syntax in a strict  
>> setting: The
>> *where* clause.  The problem is that it's natural to write a bunch of
>> bindings in a where clause which only scope over a few conditional
>> clauses.  I'm talking about stuff like this:
>>
>> f x
>>   | p x               = ..... a ...a . a .... a ...
>>   | complex_condition = ......... b .. b ... b ......
>>   | otherwise         = ..... a ....... b .....
>>   where a = horrible expression in x which is bottom when
>> complex_condition is true.
>>         b = nasty expression in x which doesn't terminate when p x
>> is true.
>>         complex_condition = big expression which
>>                              goes on for lines and lines
>>                              and would drive the reader
>>                              insane if it occurred in line.
>
> Surely it would not be too difficult for the compiler to only  
> evaluate the where bindings that are relevant depending on which  
> guard evaluates to True ie in your example, the binding for a would  
> be evaluated if p x is True, otherwise the complex_condition would  
> be evaluated, and if True, b would be evaluated, otherwise a and b  
> would be evaluated: ...

In principle, yes, this is eminently doable.  But the translation  
becomes surprisingly messy when the bindings in question are mutually  
recursive.  Certainly it's not a simple syntax-directed translation,  
in contrast to essentially every other piece of syntactic sugar in  
the language.

-Jan-Willem Maessen



More information about the Haskell-Cafe mailing list