let (d,k) = (g x y, h x d) ..

Jerzy Karczmarczuk karczma@info.unicaen.fr
Fri, 27 Jun 2003 11:28:44 +0200


Serge D. Mechveliani wrote:

 >   f' n m l = let (d,k) = (gcd n m, quot n d)  in  (k, l*k)
...
 >
 > The intended program was
 >
 >   f  n m l = let {d = gcd n m;  k = quot n d} in  (k, l*k)
 >
 > But f' gives the intended results, at least in the GHC
 > implementation.
 > So that I did not notice the `error' for a long time.
 >
 > Is really the Haskell pattern matching semantic so that f and f'
 > are equivalent ?


But, in a lazy language it is the same, the let defs. are processed
colaterally, the only difference is the (possibly optimized away)
creation of the intermediate tuple (d,k).

Jerzy Karczmarczuk