[Haskell-cafe] Lazy language on JVM/CLR
tom at lokhorst.eu
Tue Feb 9 07:59:07 EST 2010
About a year ago, Jeroen Leeuwenstein and I worked on CLR backend for
the Utrecht Haskell Compiler (UHC) .
That was a one-month project for a seminar at Utrecht University, and
the backend is far from being complete. But we did make some
A particular caveat of the UHC is that it does whole program analysis,
so we had access to the entire program and all libraries at compile
A benefit of using the CLR was that it does support tail calls. So a
mutual recursive function definition can loop a million times without
creating a stack overflow.
Our main problem (in efficiency) was lazy evaluation, not knowing the
difference between an evaluated `int` and a possible thunk
`Lazy<int>`. That meant we had to wrap _everything_ in a layer of
> add :: Int -> Int -> Int
> add x y = x + y
> add 2 4
Becomes something equivalent to:
> public int add(Lazy<int> x, Lazy<int> y)
> return x.Force() + y.Force();
> add(new Lazy(() => 2), new Lazy(() => 4));
Having a strictness analyser would have helped tremendously.
Also, I wonder if there is some efficient way of implementing the Lazy
class, perhaps by having the Force method using runtime code
generation to override itself. I don't know if this is possible, but I
vaguely remember the Dynamic Language Runtime on .NET doing something
I find this an interesting topic, so when you do have something more,
please let us know on this list.
- Tom Lokhorst
On Tue, Feb 9, 2010 at 1:42 AM, Tony Morris <tonymorris at gmail.com> wrote:
> I have hypothesised a pure, lazy language on the JVM and perhaps the
> .NET CLR with FFI to .NET/Java libraries. I foresee various problems but
> none that are catastrophic; just often requiring a compromises,
> sometimes very unattractive compromises. I have authored several
> libraries in the same vain as pure, lazy programming to run on the JVM
> in Java and Scala programming languages.
> I expect others have forethought and perhaps even experimented with such
> a language. Are there any dangers to be wary of that undo the entire
> Thanks for any insights.
> Tony Morris
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe