2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section[PrelInfo]{The @PrelInfo@ interface to the compiler's prelude knowledge}
11 wiredInThings, basicKnownKeyNames,
14 -- Random other things
15 maybeCharLikeCon, maybeIntLikeCon,
18 isNumericClass, isStandardClass
22 #include "HsVersions.h"
24 import PrelNames ( basicKnownKeyNames,
25 hasKey, charDataConKey, intDataConKey,
26 numericClassKeys, standardClassKeys )
28 import PrimOp ( PrimOp, allThePrimOps, primOpOcc, primOpTag, maxPrimOpTag )
29 import DataCon ( DataCon )
30 import Id ( Id, idName )
31 import MkId ( mkPrimOpId, wiredInIds )
32 import MkId -- All of it, for re-export
33 import Name ( nameOccName )
34 import TysPrim ( primTyCons )
35 import TysWiredIn ( wiredInTyCons )
36 import HscTypes ( TyThing(..), implicitTyThings, GenAvailInfo(..), RdrAvailInfo )
37 import Class ( Class, classKey )
38 import Type ( funTyCon )
39 import TyCon ( tyConName )
42 import Array ( Array, array, (!) )
45 %************************************************************************
47 \subsection[builtinNameInfo]{Lookup built-in names}
49 %************************************************************************
51 Notes about wired in things
52 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
53 * Wired-in things are Ids/TyCons that are completely known to the compiler.
54 They are global values in GHC, (e.g. listTyCon :: TyCon).
56 * A wired in Name contains the thing itself inside the Name:
57 see Name.wiredInNameTyThing_maybe
58 (E.g. listTyConName contains listTyCon.
60 * The name cache is initialised with (the names of) all wired-in things
62 * The type checker sees if the Name is wired in before looking up
63 the name in the type environment. So the type envt itself contains
66 * MkIface prunes out wired-in things before putting them in an interface file.
67 So interface files never contain wired-in things.
71 wiredInThings :: [TyThing]
74 [ -- Wired in TyCons and their implicit Ids
76 , concatMap implicitTyThings tycon_things
82 , map (AnId . mkPrimOpId) allThePrimOps
85 tycon_things = map ATyCon ([funTyCon] ++ primTyCons ++ wiredInTyCons)
88 We let a lot of "non-standard" values be visible, so that we can make
89 sense of them in interface pragmas. It's cool, though they all have
90 "non-standard" names, so they won't get past the parser in user code.
92 %************************************************************************
96 %************************************************************************
99 primOpIds :: Array Int Id -- Indexed by PrimOp tag
100 primOpIds = array (1,maxPrimOpTag) [ (primOpTag op, mkPrimOpId op)
101 | op <- allThePrimOps]
103 primOpId :: PrimOp -> Id
104 primOpId op = primOpIds ! primOpTag op
108 %************************************************************************
110 \subsection{Export lists for pseudo-modules (GHC.Prim)}
112 %************************************************************************
114 GHC.Prim "exports" all the primops and primitive types, some
118 ghcPrimExports :: [RdrAvailInfo]
120 = map (Avail . nameOccName . idName) ghcPrimIds ++
121 map (Avail . primOpOcc) allThePrimOps ++
122 [ AvailTC occ [occ] |
123 n <- funTyCon : primTyCons, let occ = nameOccName (tyConName n)
128 %************************************************************************
130 \subsection{Built-in keys}
132 %************************************************************************
134 ToDo: make it do the ``like'' part properly (as in 0.26 and before).
137 maybeCharLikeCon, maybeIntLikeCon :: DataCon -> Bool
138 maybeCharLikeCon con = con `hasKey` charDataConKey
139 maybeIntLikeCon con = con `hasKey` intDataConKey
143 %************************************************************************
145 \subsection{Class predicates}
147 %************************************************************************
150 isNumericClass, isStandardClass :: Class -> Bool
152 isNumericClass clas = classKey clas `is_elem` numericClassKeys
153 isStandardClass clas = classKey clas `is_elem` standardClassKeys
154 is_elem = isIn "is_X_Class"