[Haskell-cafe] Haskell source transformer?

Dimitry Golubovsky golubovsky at gmail.com
Thu Nov 30 00:04:19 EST 2006


Hi,

In order to automatize the creation of W3C DOM typesafe wrapper (this
is needed for my Haskell->Javascript stuff) I am processing the OMG
IDL files that contain interface definitions for DOM methods and
attributes with HDirect.

It works in general (for some reason it didn't like "boolean" type, so
I used a preprocessor to redefine it as "Boolean"), and outputs some
Haskell code full of foreign calls, yet it contains what I need: type
signatures.

For example, for the method "appendChild" it outputs:

appendChild :: Node a1
            -> Node a0
            -> Prelude.IO (Node ())
appendChild newChild iptr =
  do
    o_appendChild <- Com.invokeIt (\ methPtr iptr ->
Foreign.ForeignPtr.withForeignPtr newChild (\ new
    unmarshallNode o_appendChild

(above lines of code may be truncated, they are just for illustration)

This is almost it, but I need to replace the return type (using the JS
monad instead of IO), and replace the method implementation with
something else, based on unsafeJS.

In some other cases I may need to modify type declarations, etc.

I know there is a Haskell syntax parser around (maybe, more than one).
Does anybody know of any utility based on such parser that does things
I need, or rather a library on top of the parser? I just would like to
avoid reinventing the wheel.

Last thing I want to do is to change sources of HDirect.

Thanks.

-- 
Dimitry Golubovsky

Anywhere on the Web


More information about the Haskell-Cafe mailing list