r/haskellquestions • u/spartan12321 • Oct 10 '18
Multiple variables defined inside function
I get error on this code if i want ot declare second variable
foo x =
y + yy
where y = x + 1
yy = (-x)
My example is much more complicated, this is simplifed version. I can't find example of declaring multiple variable inside function. Is this incorect way of thinking and I should add two functions as parameters instead?
0
Upvotes
12
u/Tayacan Oct 10 '18
So it's hard to see because of the way you formatted your code, but it's probably an indentation error. Within a where-block, everything should line up, like this:
Or perhaps like this: