True multi stage Haskell
John Lato
jwlato at gmail.com
Mon Nov 27 01:16:51 UTC 2017
Hi Tim,
Several years ago I wrote a proof of concept of one way to implement this
in Haskell,
http://johnlato.blogspot.com/2012/10/runtime-meta-programming-in-haskell.html
.
I used TH to automatically lift expressions into a newtype-wrapped ExpQ
that could be used for staged evaluation. More than one stage would
probably have been tedious though, and a major problem with any non-trivial
code was getting all the imports in place. I do think it would have been
possible to automatically track imports though.
Of course that was 5 years ago, so state of the art has moved on. TH has
better facilities for this now, and the ghc API probably has something
better too.
On Fri, Nov 17, 2017, 10:06 Tim Sheard <sheard at pdx.edu> wrote:
> After many years of hoping someone else would do this, I would like to
> make GHC into a true multi-stage programming language. Here is how I
> thought I might approach this.
>
> 1) Use the GHC as a library module.
> 2) Use the LLVM backend.
>
> I have no experience with either of these tools.
> Lets start simple, How would I write functions like
>
> compile :: String -> IO PtrToLLVMCode -- where the string is a small
> Haskell program.
> llvmCompile :: PtrToLLVMCode -> IO PtrToMachineCode
> jumpTo:: PtrToMachineCode -> IO ans -- where ans is the "type" of the
> string.
>
>
> Any thoughts on how to get started? What papers to read, examples to
> look at?
>
> I'd love to move to some more disciplined input type, a sort of (mono)
> typed program
> representation (with similar complexity) to Template Haskell Exp type.
>
> where (Exp t) is a data structure representing a Haskell program of type t.
>
> All offers of advice accepted. I'm trying to get started soon, and good
> advice
> about what to avoid is especially welcome. If any one wanted to help
> with this,
> that would be great.
>
> Tim Sheard
>
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20171127/721b28f9/attachment.html>
More information about the ghc-devs
mailing list