I need some clarification about laziness with Haskell.
If I have this function:
myFunction arg
| arg == 1 = a
| arg == 2 = a*b
| arg == 3 = b+c
| otherwise = (a+b)*c
where
a = ...
b = ...
c = ...
d = ...
When I call myFunction 1
, Haskell will evaluate only the a = ...
function, neither b nor c, nor d.
But if I write
myFunction arg
| arg == 1 = a
| arg == 2 = a*b
| arg == 3 = b+c
| otherwise = (a+b)*c
where
(a,b,c,d) = anotherFunction arg
What will Haskell's behaviour be?
- Will it evaluate only a and 'propagate' the lazyness to
anotherFunction
? - Or, will it evaluate the whole tuple (a,b,c,d) as result of
anotherFunction
?