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

Brian Hulley brianh at metamilk.com
Fri Feb 3 20:16:43 EST 2006


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:

f x
     | p x = let a = ..... in ....a a ...
     | otherwise = let
                                 complex_condition = ...
                                 b = ...
                          in
                                if complex_condition then
                                       .... b .... b
                               else let
                                             a = ..... a
                                      in
                                            .... a.....b

where all the messy (possibly duplicated) let's are generated by the 
compiler so the user can still use the nice where syntax.

Regards, Brian. 



More information about the Haskell-Cafe mailing list