[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] A question on DSL's

Subject: Re: [Haskell-cafe] A question on DSL's
From: John Van Enk
Date: Mon, 4 Jan 2010 12:21:06 -0500
To start with, can you clarify that you are looking for an Embedded DSL (sometimes called Light Weight DSL)?

A _proper_ DSL has its own interpreter/compiler where an EDSL/LwDSL leverages the compiler of a host language (in this case, Haskell).

Assuming you're referring to an EDSL, I'll respond. :)

I don't think the second option is ever used. Modifying the compiler backend doesn't seem to make a lot of sense to me. I'm not aware of any circumstance where this has been done.

Your first option is closer. Generally, when emitting some sort of target code from a large EDSL, you'll have two stages. Your first takes the embedded syntax of your EDSL and converts it to an Abstract Syntax Tree. Your second stage accepts the AST as input and emits target code.

Take Tom Hawkins' Atom EDSL as an example. When we write Atom code, we're building up an AST. After the AST is built up, the "compile" function converts the AST to C code.

For smaller EDSLs, it's more than possible to have the functions themselves emit the code we're after (rather than relying on an AST and compile function).

Is this what you're looking for?


On Mon, Jan 4, 2010 at 12:14 PM, CK Kashyap <[email protected]> wrote:
I am not sure if I'm using DSL in the right context here but I am referring to those solutions that allow us to write code in Haskell and generate a target code source code of another language or even object code for that matter. I am aware of two ways of achieving this -
1. Implement functions that emit the target code - that is, when the Haskell code is compiled and run, the target code is emitted
2. Modify the Haskell compiler's back end to emit the code - that is when the Haskell code is compiled the target code is emitted

I am not sure if there are more ways (hybrid perhaps) ...

My question is,  when would I chose one approach over the other?


Haskell-Cafe mailing list
[email protected]

Haskell-Cafe mailing list
[email protected]
<Prev in Thread] Current Thread [Next in Thread>