How to get types including constraints out of TypecheckedModule

Daniel Gröber dxld at darkboxed.org
Fri Sep 18 04:59:46 UTC 2015


Hi ghc-devs,

I have a question and some code to ponder on for you all: In ghc-mod we have
this very useful command to get the type of something in the middle of a module,
i.e. not a toplevel binder. Essentially we just optain a TypecheckedModule and
traverse the tm_typechecked_source and then extract the Types from that in
various places.

This all works nice and well but we have one problem, namely the contraints are
missing from all types. Now I'm sure there's a good reason GHC doesn't keep
those inline in the syntax tree but my question is how do I get them?

I've created a testcase that demonstrates the problem:

    $ git clone https://gist.github.com/DanielG/1101b8273f945ba14184
    $ cd 1101b8273f945ba14184
    $ ghc -package ghc -package ghc-paths GhcTestcase.hs
    $ ./GhcTestcase
    Type: a

Even though the type of the binder I'm looking at has the type `Num a => a`.

--Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20150918/14db602a/attachment.sig>


More information about the ghc-devs mailing list