GHC as a library

Simon Peyton-Jones simonpj at microsoft.com
Wed May 30 12:23:00 EDT 2007


| 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.)

The Ids are the variables declared in the module, and they each have a type (use idType).


In exchange, would you like to document what you have learned?  Here for example:
        http://haskell.org/haskellwiki/GHC/As_a_library


Many thanks

Simon


More information about the Glasgow-haskell-users mailing list