In Haskell, declaration order in let/where constructs does not matter, for example:
f x = let g1 x y = if x>y then show x else g2 y x
g2 p q = g1 q p
in ...
where g2
used in g1
before its declaration.
But this is not a case in Ocaml:
# let a = b in
let b = 5 in
a;;
Warning 26: unused variable b.
Error: Unbound value b
Is there a reason why OCaml doesn't behave like Haskell? In the absence of forward declaration, this feature seems useful to me.
Is it because of strict evaluation in OCaml but lazy in Haskell?
let a = b in let b = 5 in a
is still illegal. – Fred Foo