miscellaneous Core questions
Max Bolingbroke
batterseapower at hotmail.com
Fri Feb 25 09:27:32 CET 2011
On 24 February 2011 19:08, Adam Megacz <megacz at cs.berkeley.edu> wrote:
> - Can I count on the desugarer and core-to-core passes preserving the
> syntactic order of the branches in a (Let (Rec branches) e)?
Absolutely not. They will in general be reordered, eliminated, whatever.
> - It isn't possible for a single Case to have *both* LitAlt's and
> DataAlt's, is it? Seems like any given Case should have only one
> or the other (and possibly a DEFAULT).
Right.
> - In SystemFC1 the (+>)_\kappa operator is indexed by a kind. If I
> encounter this in Core:
Dimitrios answered this.
> - I haven't been able to figure out how to ask GHC for the Kind of a
> Type. I expected to find a "kindOfType" or similar but couldn't
> find it in Type.lhs or TypeRep.lhs. Does GHC know how to compute
> the Kind of a Type?
Look in Coercion.lhs: there is a function typeKind
> - Is there a way to extract the varType field from a Var? It doesn't
> seem to be exported from Var.lhs; I had to add my own function to that
> file so I could access this field in other modules.
It is exported in my current checkout, and reexported from Id.lhs as idType.
> - Is it possible to turn a Name (say, of some magic identifier from
> PrelNames.lhs) into a global Var outside of GHC's various monads?
> I'd like to add a Var for a global name in a core-to-core pass that
> isn't of monadic type.
I'm not sure what you are asking. You want to take a Name and make it
into a Var - but a Var has a lot more fields (not least the type of
the name), so where are you getting them from? You also say a "global"
Var - do you mean in the sense that is is a GlobalId?
I assume what you are trying to do is take e.g. newStablePtrName from
PrelNames and turn it into a Var referencing a "newStablePtr"
function. AFAIK this is not really possible without being in one of
the magic monads that carry the appropriate state since it may involve
making GHC read and parse an interface file for the relevant modules
and generally set up its internal state pertaining to those modules.
Max
More information about the Cvs-ghc
mailing list