pselm / signals

Purescript implementation of Elm 0.16's signals modules
Other
91 stars 2 forks source link

Converting Elm syntax to Purescript #11

Closed rgrempel closed 6 years ago

rgrempel commented 8 years ago

I was thinking about the process of converting Elm syntax to Purescript syntax ... all the little stuff, like "data vs. type" and "type vs. type alias" etc.

It occurred to me that there already is a program called elm-format, which re-formats Elm syntax in a standardized way. It appears to construct an AST of the source code, and then "interprets" the AST by outputting text in a standardized format.

I wonder if one could simply add a new target for Purescript? That is, given the AST, there wouldn't appear to be any fundamental problem with simply changing the interpreter to output Purescript syntax rather than Elm syntax.

Plus, I could build in some knowledge about purescript-elm -- for instance, modifying the standard imports to refer to their purescript-elm equivalents, and perhaps ironing out a few other things.

The Purescript code it would produce would often need some changes in order to compile, but it could probably be pretty close.

So, I'll take a more serious look at this once I've got the virtual-dom and HTML stuff working.

rgrempel commented 8 years ago

I've done a proof-of-concept here:

https://github.com/rgrempel/elm-format-purescript

So far, I've just made one tiny change -- to use Purescript's format for doc comments. It works like a charm. So, this should be viable.

I'll do some more work on it the next time I've got an Elm file to convert ...

rgrempel commented 8 years ago

I've added a few more features ... stuff like :: vs. : and type alias vs. type and type vs. data and a few others.

Next step would be to clean up the documentation, names, etc. and publish at least a partly-working binary ...

rgrempel commented 6 years ago

I'll close this here ... I'll gradually improve the tool as I work on converting more example Elm programs.