[Haskell-cafe] I love purity, but it's killing me.
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).
> 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
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
More information about the Haskell-Cafe