In Haskell, the declaration order in let / where clauses does not matter, for example:
fx = let g1 xy = if x>y then show x else g2 yx g2 pq = g1 qp in ...
where g2 used in g1 before its declaration. But this does not apply to Ocaml:
# let a = b in let b = 5 in a;; Warning 26: unused variable b. Error: Unbound value b
Is there a reason OCaml doesn't behave like Haskell? In the absence of a direct declaration, this function seems to me useful.
Is it because of strict evaluation in OCaml, but lazy in Haskell?
source share