I’m curious about the relationship between static typing and lazy functional languages. Is it possible to have a dynamic lazy functional language, for instance? It seems as if all of the lazy functional languages out there are statically typed (Haskell, Miranda, etc), and all of the dynamic functional languages use strict evaluation (Clojure, Scheme, etc).
In particular, the Wikipedia article on Lazy evaluation reads:
However, with lazy evaluation, it is difficult to combine with
imperative features such as exception handling and input/output,
because the order of operations becomes indeterminate. Lazy evaluation
can introduce space leaks.
What is the role that static typing plays in preventing space leaks?
I don’t believe that static types play a role at all. For example, consider the untyped lazy language, Lazy Racket. I haven’t heard any indication that it leaks space in a way that Haskell (for example) does not.
Side effects, on the other hand, are a problem because humans find the order of evaluation of strict evaluation to be (relatively) natural, and call-by-need is much harder to mentally predict.