
11 Oct
2004
11 Oct
'04
10:30 a.m.
Serge,
How do you think, is the program (1) equivalent to (2) in the meaning of Haskell-98 ?
(1) (\ x -> (if p x then foo (g x) else foo (h x)) where p ... g ... h ... foo ... )
(2) (\ x -> foo ((if p x then g x else h x) where p ... g ... h ... foo ... ) )
Both examples are illegal -- there are no where-expressions in Haskell, only where-equations. Ignoring the local definition part, however, the answer is no. Lifting foo out of the branches of the conditional is only valid if foo is strict. Colin R