2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section[PrelInfo]{The @PrelInfo@ interface to the compiler's prelude knowledge}
8 -- The above warning supression flag is a temporary kludge.
9 -- While working on this module you are encouraged to remove it and fix
10 -- any warnings in the module. See
11 -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
18 wiredInThings, basicKnownKeyNames,
21 -- Random other things
22 maybeCharLikeCon, maybeIntLikeCon,
25 isNumericClass, isStandardClass
29 #include "HsVersions.h"
31 import PrelNames ( basicKnownKeyNames,
32 hasKey, charDataConKey, intDataConKey,
33 numericClassKeys, standardClassKeys )
35 import PrimOp ( PrimOp, allThePrimOps, primOpOcc, primOpTag, maxPrimOpTag )
36 import DataCon ( DataCon )
37 import Id ( Id, idName )
38 import MkId -- All of it, for re-export
39 import Name ( nameOccName )
40 import TysPrim ( primTyCons )
41 import TysWiredIn ( wiredInTyCons )
42 import HscTypes ( TyThing(..), implicitTyThings, GenAvailInfo(..), RdrAvailInfo )
43 import Class ( Class, classKey )
44 import Type ( funTyCon )
45 import TyCon ( tyConName )
48 import Array ( Array, array, (!) )
51 %************************************************************************
53 \subsection[builtinNameInfo]{Lookup built-in names}
55 %************************************************************************
57 Notes about wired in things
58 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
59 * Wired-in things are Ids/TyCons that are completely known to the compiler.
60 They are global values in GHC, (e.g. listTyCon :: TyCon).
62 * A wired in Name contains the thing itself inside the Name:
63 see Name.wiredInNameTyThing_maybe
64 (E.g. listTyConName contains listTyCon.
66 * The name cache is initialised with (the names of) all wired-in things
68 * The type checker sees if the Name is wired in before looking up
69 the name in the type environment. So the type envt itself contains
72 * MkIface prunes out wired-in things before putting them in an interface file.
73 So interface files never contain wired-in things.
77 wiredInThings :: [TyThing]
78 -- This list is used only to initialise HscMain.knownKeyNames
79 -- to ensure that when you say "Prelude.map" in your source code, you
80 -- get a Name with the correct known key
83 [ -- Wired in TyCons and their implicit Ids
85 , concatMap implicitTyThings tycon_things
91 , map (AnId . mkPrimOpId) allThePrimOps
94 tycon_things = map ATyCon ([funTyCon] ++ primTyCons ++ wiredInTyCons)
97 We let a lot of "non-standard" values be visible, so that we can make
98 sense of them in interface pragmas. It's cool, though they all have
99 "non-standard" names, so they won't get past the parser in user code.
101 %************************************************************************
105 %************************************************************************
108 primOpIds :: Array Int Id -- Indexed by PrimOp tag
109 primOpIds = array (1,maxPrimOpTag) [ (primOpTag op, mkPrimOpId op)
110 | op <- allThePrimOps]
112 primOpId :: PrimOp -> Id
113 primOpId op = primOpIds ! primOpTag op
117 %************************************************************************
119 \subsection{Export lists for pseudo-modules (GHC.Prim)}
121 %************************************************************************
123 GHC.Prim "exports" all the primops and primitive types, some
127 ghcPrimExports :: [RdrAvailInfo]
129 = map (Avail . nameOccName . idName) ghcPrimIds ++
130 map (Avail . primOpOcc) allThePrimOps ++
131 [ AvailTC occ [occ] |
132 n <- funTyCon : primTyCons, let occ = nameOccName (tyConName n)
137 %************************************************************************
139 \subsection{Built-in keys}
141 %************************************************************************
143 ToDo: make it do the ``like'' part properly (as in 0.26 and before).
146 maybeCharLikeCon, maybeIntLikeCon :: DataCon -> Bool
147 maybeCharLikeCon con = con `hasKey` charDataConKey
148 maybeIntLikeCon con = con `hasKey` intDataConKey
152 %************************************************************************
154 \subsection{Class predicates}
156 %************************************************************************
159 isNumericClass, isStandardClass :: Class -> Bool
161 isNumericClass clas = classKey clas `is_elem` numericClassKeys
162 isStandardClass clas = classKey clas `is_elem` standardClassKeys
163 is_elem = isIn "is_X_Class"