[Haskell-cafe] ghc-api Static Semantics?
nominolo at googlemail.com
Wed Jan 25 20:29:34 CET 2012
I assume by static semantics you mean the renamed Haskell source code.
Due to template Haskell it (currently) is not possible to run the
renamer and type checker separately. Note that the type checker
output is very different in shape from the renamed output. The
renamed output mostly follows the original source definitions, but the
type checker output is basically only top-level definitions (no
instances, classes have become data types, etc.) so it can be a bit
tricky to map types back to the input terms.
Still, I think solution with the best trade-off between
maintainability and usability is to use the GHC API and annotate a
haskell-src-exts representation of the given input file. The GHC AST
structures are volatile, and have lots of ugly invariants that need to
be maintained. E.g., some fields are only defined after renaming and
are others may no longer be defined after renaming. If you look at
those fields when they are not defined, you get an error.
Let me know if you decide to take on this project.
On 24 January 2012 10:35, Christopher Brown <cmb21 at st-andrews.ac.uk> wrote:
>> Have you looked at ghc-syb-utils, which gives a neat way to print an AST?
> Yes I found that yesterday!
>> JP Moresmau
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
Push the envelope. Watch it bend.
More information about the Haskell-Cafe