GHC API: getting the unfolding of a "strange" Id

Christiaan Baaij christiaan.baaij at
Wed Mar 26 16:40:31 UTC 2014

Dear list,

I'm using the GHC API to get Core Expressions from haskell interface (.hi) files, and have encountered a strange kind of 'Id' for which I can't seem to get the unfolding:

The properties of this 'Id' are the following:
- varName: $fNumFixed2 
- IdDetails: VannillaId
- Pretty print of IdInfo.inlinePragInfo: [Always]
- IdInfo.unfoldingInfo: NoUnfolding

The source file which gives rise to this 'Id' is:
As you can see, the file is compiled with: -fexpose-all-unfoldings

The '$f' prefix seems to indicate that the 'Id' is a Dictionary Function, so I was expecting its 'IdInfo.unfoldingInfo' to be a 'DFunUnfolding'.
Given that pretty printing 'inlinePragInfo' gives me '[Always]', I would expect to have a usable 'Unfolding' in general.
How can GHC inline the body of this 'Id' if it has no unfolding?

Also, if I compile the file with "-O0 -fno-omit-interface-pragmas", the $fNumFixed2 'Id' is no longer included in the interface file.
At positions where "$fNumFixed2" was originally used, a equality constraint can eventually be found:

Using -O:
       @(GHC.TypeLits.+ 4 4)

Using -O0 -fno-omit-interface-pragmas:
       @(GHC.TypeLits.<=? 1 (GHC.TypeLits.+ 4 4))

So my question is, what kind of "strange" 'Id' is this $fNumFixed2?
And how can I get the Core expression for this 'Id' from the interface file?
And if I can't get it from the interface file, is there a straightforward way to generate it from the 'Id'?



More information about the Glasgow-haskell-users mailing list