I'm developing a virtual machine for purely functional programs, and I would like to be able to test and use the the wide variety of Haskell modules already available. The VM takes as input essentially terms in the untyped lambda calculus. I'm wondering what would be a good way to extract such a representation from modern Haskell modules (eg. with MPTC's, pattern guards, etc.). I did a little research and there doesn't seem to be a tool that does this already (I would be delighted to be mistaken), and that's okay. I'm looking for an approach.
GHC Core seems too operationally focused, especially since one of the things the VM does is to change the evaluation order significantly. Are there any accessible intermediate representations that correspond more closely to the lambda calculus?
The External Core for GHC is about as close to the lambda calculus as you're going to get, using GHC. Here is a link straight to the expression type if you want to jump right in.
EHC used to have this flow between representations:
HS -> EH -> Core -> Grin -> Silly
HS is obviously Haskell, EH is less sugary and used by the type checker, Core is the analogue to GHC's Core and Grin and Silly are lower level than that.
There is a paper describing EHC's architecture by Jeroen Fokker, where I've cribbed the above from, but it's probably out of date (I don't know that EHC still uses the Silly representation). I think that EHC provides parsers and pretty printers for each of its internal representations, which would be handy.
There's also York.Core from YHC which I've seen people speak more favorably of then GHC Core, but I don't know if there is a means of compiling "modern" Haskell into York.Core.
Hm... Ever heard of the Haskell Kernel? I'm not sure what you need. It's some kind of desugared Haskell, and is essentially defined in the Haskell report. I'm not sure whether this is what you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With