
20 Jul
2009
20 Jul
'09
2:14 a.m.
I. J. Kennedy wrote:
GHC complains that u is out of scope in the following definition:
f n = let u = [1..n] in g n where g x = u
Why? I understand that it's "just the way Haskell works", but I'm wondering about the rationale of the language designers when deciding on this scoping behavior.
the reason we need "where", is to scope over a function clause. Do you know about guards? like, here's a (very stupid) example where "let" doesn't work, so "where" scoping is needed: f n | np == 0 = 1 + add | np == 1 = 3 + add where np = n + 1 add = n + 2 -Isaac