After some more analysis, I found out the following two details:

The output of 'ghc -show-iface':
be3312a893800a4aa077856449084da7
  $fNumFixed2 :: forall (n::GHC.TypeLits.Nat). (GHC.TypeLits.<=) 1 n
    {- Strictness: b -}

$fNumFixed2 is only included in the interface file because of -fexpose-all-unfoldings.
And appearently, the inlinePragInfo is by default set to AlwaysInline when an Id is included in the interface file.

Additionally, the Id seems to be introduced by the strictness analysis, as compiling with -fno-strictness makes the Id go away.

So I guess I should rephrase my question abit:
Why does the strictness analysis phase introduce binders for which no unfoldings are generated in the interface file?
Even when -fexpose-all-unfoldings is set.

-- Christiaan





On Wed, Mar 26, 2014 at 5:40 PM, Christiaan Baaij <christiaan.baaij@gmail.com> wrote:
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: https://github.com/christiaanb/clash-prelude/blob/master/src/CLaSH/Sized/Fixed.hs
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:
(CLaSH.Sized.Fixed.$fNumFixed2
       @(GHC.TypeLits.+ 4 4)

Using -O0 -fno-omit-interface-pragmas:
(GHC.Types.Eq#
       @GHC.Types.Bool
       @(GHC.TypeLits.<=? 1 (GHC.TypeLits.+ 4 4))
       @GHC.Types.True
         _CO_)

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'?

Cheers,

Christiaan