[Haskell-cafe] I love purity, but it's killing me.

Don Stewart dons at galois.com
Fri Feb 8 19:47:39 EST 2008

> On 2/8/08, Emil Axelsson <emax at cs.chalmers.se> wrote:
> > I know of a few of ways to express sharing in a pure language:
> >
> > 1) "Observable sharing", which, in general, is unsafe.
> > 2) Using Template Haskell
> > 3) Matthew Naylor has done some work on "expressible sharing", which has
> > 4) Use a monad (but I'm sure this is what you're trying to avoid).
> Or...
> 5) Forget embedding the DSL, and write a direct compiler.
> In addition to the sharing problem, another shortcoming of Haskell
> DSLs is they can not fully exploit the benefits of algebraic
> datatypes.  Specifically, pattern matching ADTs can only be used to
> control the compile-time configuration of the target, it can't be used
> to describe the target's behavior -- at least for DSLs that generate
> code that executes outside of Haskell's runtime.
> Writing a real compiler would solve both of these problems.  Is there
> any Haskell implementation that has a clean cut-point, from which I
> can start from a fully type-checked, type-annotated intermediate
> representation?

Taking the output of GHC's intermediate phase, after optimising
leaves you with type checked, optimised, 'Core' -- basically
lambda calculus with extras.

It's a good start if you then want to hand-compile that down.

Extract it with -fext-core

-- Don

More information about the Haskell-Cafe mailing list