GHC as a library
Simon Marlow
simonmarhaskell at gmail.com
Thu May 31 09:49:34 EDT 2007
Simon Peyton-Jones wrote:
> | In typecheckedSource, I can only access the function definitions with
> | type annotations, but not the data type declaration.
> | In checkedModuleInfo, I can only access the "Names" of the exported
> | entities, and but not their (inferred) types are not present.
>
> You have easy access to the data decls:
>
> In a ModuleInfo is a TypeEnv.
> The range of the type env (gotten with typeEnvElts) are TyThings.
> A TyThing can be
> a Id
> a Class
> a TyCon
> a DataCon
>
> So just pull out those TyCons and away you go! (Lots of accessor functions for TyCons in module TyCon.)
Many of the TyCon accessor functions are available from module GHC. If you find
there's something from that you need that exists but isn't exported by the GHC
module, then please let us know - this is one example of the kind of feedback we
need to improve the GHC API. In theory, you should only need to import GHC; in
practice this often isn't the case, which is why we haven't gone for strict
hiding of everything except GHC in the package.
Cheers,
Simon
More information about the Glasgow-haskell-users
mailing list