Thanks Jasper ... Thanks John, While most of the use case I had in mind seems to fit the EDSL description, I had some in the proper DSL category as well... So, my prejudice had been towards option one - and I was unable to visualize a situation where option 1 would not work - or become too problematic or option 2 becomes too simple.
I was just thinking of implementing an OS kernel (monolithic to start with) using Haskell - via option 1. Then again, if I understand right, House was done by modifying GHC ... So, I guess it'll help me if I can see some example situations where modifying GHC's back end would be a better/only option. The main reason I am asking this is to make sure I don't miss out some obvious pitfall in my OS implementation via option 1. Regards, Kashyap > >From: John Van Enk <[email protected]> >To: CK Kashyap <[email protected]> >Cc: [email protected] >Sent: Mon, January 4, 2010 10:51:06 PM >Subject: Re: [Haskell-cafe] A question on DSL's > > >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? > > >/jve > > >On Mon, Jan 4, 2010 at 12:14 PM, CK Kashyap <[email protected]> wrote: > >>>Hi, >>>>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? >> >>>>Regards, >>>>Kashyap >> >> >> >> >> >>>>_______________________________________________ >>>>Haskell-Cafe mailing list >>[email protected] >>http://www.haskell.org/mailman/listinfo/haskell-cafe >> >
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
