GHC Core questions

Tim Chevalier catamorphism at gmail.com
Sun Jul 1 14:55:29 EDT 2007


On 7/1/07, Neil Mitchell <ndmitchell at gmail.com> 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?
>

As Aaron said, the ModGuts data structure represents everything that's
in a Core module; right now the compileToCore function that I wrote
just selects out the field containing the [CoreBind] and returns it. I
could change it to return the entire ModGuts and then the user would
be responsible for selecting out the bindings, type environment, etc.
Or I could change it to return a pair of the bindings and the type
environment (containing the bindings for user-defined data
constructors). I guess in principle, users might want to inspect the
other fields in ModGuts, so maybe that's the best way to go. Does
anyone else have thoughts?


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

If you add  "-dppr-debug" to the flags for the GHC session, and then
show things using "ppr" rather than "show", it should show the
uniques.

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

As Aaron said, no, but I remember Aaron did suggest in the past that
an option could be added to generate a "complete" .hi file, containing
unfoldings (i.e., Core code) for all exported functions, not just
those that GHC thinks should be inlined. So that's something we could
discuss if you think it would be useful to you.

Cheers,
Tim

-- 
Tim Chevalier* catamorphism.org *Often in error, never in doubt
"In a land of quince jelly, apple butter, apricot jam, blueberry
preserves, pear conserves, and lemon marmalade, you always get grape
jelly."  --William Least Heat-Moon



More information about the Cvs-ghc mailing list