Top-level type signatures in TcGblEnv?

Simon Peyton-Jones simonpj at
Mon Feb 25 16:22:02 CET 2013

Can't you just use the range of the tcg_type_env?


From: Edsko de Vries [mailto:edskodevries at]
Sent: 18 February 2013 14:03
To: Simon Peyton-Jones
Cc: ghc-devs at
Subject: Top-level type signatures in TcGblEnv?

Dear Simon, other ghc devs,

I hooked into genericHscRecompile to traverse the typechecked source and construct an environment of type

     [(SrcSpan, Id)]

recording all identifiers in the source with their type, definition site, etc. To be precise, I am traversing the

    tcg_binds     :: LHsBinds Id,           -- Value bindings in this module

field of the TcGblEnv structure returned by the type checker. The problem is that I have so far been unable to find top-level user-supplied type annotations inside LHsBinds. The closest thing I've found is the PostTcType of a MatchGroup, but that is not Located; what I'm really looking for is an LSig.

Now, let-bindings get a HsValBindsLR instead of an LHsBinds, and that *does* contain signatures. My question is two-fold:

1. First, am I missing something? Are there LSigs somewhere inside the TcGblEnv where I simply haven't seen them?

2. If not, is there a good reason why tcg_binds is an LHsBinds rather than an HsValBindsLR? And if there isn't, would you accept a patch making the change?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list