GHC Core questions

Aaron Tomb atomb at soe.ucsc.edu
Sun Jul 1 12:34:03 EDT 2007


On Jul 1, 2007, at 5:37 AM, Neil Mitchell wrote:

> Hi,
>
> Thanks to all the help I've now managed to get GHC Core converted to
> Yhc Core (the source is at the end of this mail, if anyone wants a
> look). I have three remaining issues:
>
> 1) Data types (i.e. data/newtype) are not represented in [CoreBind] at
> all, as far as I can tell. Is Core meant to keep a list of the data
> types? If not, could they be added?

The entire contents of a module is contained in either a ModGuts or a  
CgGuts structure (depending on where in the processing pipeline you  
want it). The External Core emitter takes in a CgGuts structur, which  
also contains a [TyCon]. Both structures are defined in main/ 
HscTypes.lhs.

> 2) Dictionaries sometimes seem to generate names with different Var's,
> but when show'ing those Vars, they result in the same string. Is show
> of a Var meant to be sufficient to get uniqueness back? Unfortunately
> I don't have a complete example of this, as currently the machine on
> which I did the conversion cannot connect to the internet - I will
> provide one in a few days.

Show instances in GHC are mostly meant for debugging, and thus change  
with different debugging flags turned on. Normally, all Names (and  
Vars have Names inside) are printed out as only their textual  
representation, without the unique number that differentiates them  
from each other. If you turn on various debugging flags, show will  
give you their uniques, too.

> 3) Is it possible to get the Core out of a file without having the
> source present? I suspect the answer is no. If so, is there any way to
> get the Core from the Prelude/base libraries without building GHC from
> source, since the Windows binary does not ship with Prelude.hs etc.

Not entirely. Interface files (.hi) sometimes contain some of the  
function bodies, in order to inline them, but it would be unusual for  
all of them to be present.

Aaron



More information about the Cvs-ghc mailing list