I think Haskell will just evaluate what's needed: So it's looking for x
and finds it in the where
-clause. Then I think it computes x
once and does the all
.
If you want to test it, you could write a function myall
that does a recursion like in all (==x)
, but essentially just prints out the comparing element. So you'll see, if you get a new argument each time or if it stays just the same each time.
Edit:
Here's a little function to test this: myall
just collects the first arguments and puts it in a list.
myall x [] = [x]
myall x xs = x:(myall x (tail xs))
test xs = myall (x) xs where x = head xs
If you call test [1,2,3]
, you will see that the result is [1,1,1,1]
, i.e. first x
is evaluated to 1
, after that myall
is evaluated.