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 isNoDictClass, isNumericClass, isStandardClass
22 #include "HsVersions.h"
24 import PrelNames ( basicKnownKeyNames,
25 hasKey, charDataConKey, intDataConKey,
26 numericClassKeys, standardClassKeys,
29 import PrimOp ( PrimOp, allThePrimOps, primOpOcc, primOpTag, maxPrimOpTag )
30 import DataCon ( DataCon )
31 import Id ( Id, idName )
32 import MkId ( mkPrimOpId, wiredInIds )
33 import MkId -- All of it, for re-export
34 import Name ( nameOccName )
35 import TysPrim ( primTyCons )
36 import TysWiredIn ( wiredInTyCons )
37 import HscTypes ( TyThing(..), implicitTyThings, GenAvailInfo(..), RdrAvailInfo )
38 import Class ( Class, classKey )
39 import Type ( funTyCon )
40 import TyCon ( tyConName )
43 import Array ( Array, array, (!) )
46 %************************************************************************
48 \subsection[builtinNameInfo]{Lookup built-in names}
50 %************************************************************************
52 We have two ``builtin name funs,'' one to look up @TyCons@ and
53 @Classes@, the other to look up values.
56 wiredInThings :: [TyThing]
59 [ -- Wired in TyCons and their implicit Ids
61 , concatMap implicitTyThings tycon_things
67 , map (AnId . mkPrimOpId) allThePrimOps
70 tycon_things = map ATyCon ([funTyCon] ++ primTyCons ++ wiredInTyCons)
73 We let a lot of "non-standard" values be visible, so that we can make
74 sense of them in interface pragmas. It's cool, though they all have
75 "non-standard" names, so they won't get past the parser in user code.
77 %************************************************************************
81 %************************************************************************
84 primOpIds :: Array Int Id -- Indexed by PrimOp tag
85 primOpIds = array (1,maxPrimOpTag) [ (primOpTag op, mkPrimOpId op)
86 | op <- allThePrimOps]
88 primOpId :: PrimOp -> Id
89 primOpId op = primOpIds ! primOpTag op
93 %************************************************************************
95 \subsection{Export lists for pseudo-modules (GHC.Prim)}
97 %************************************************************************
99 GHC.Prim "exports" all the primops and primitive types, some
103 ghcPrimExports :: [RdrAvailInfo]
104 = map (Avail . nameOccName . idName) ghcPrimIds ++
105 map (Avail . primOpOcc) allThePrimOps ++
106 [ AvailTC occ [occ] |
107 n <- funTyCon : primTyCons, let occ = nameOccName (tyConName n)
112 %************************************************************************
114 \subsection{Built-in keys}
116 %************************************************************************
118 ToDo: make it do the ``like'' part properly (as in 0.26 and before).
121 maybeCharLikeCon, maybeIntLikeCon :: DataCon -> Bool
122 maybeCharLikeCon con = con `hasKey` charDataConKey
123 maybeIntLikeCon con = con `hasKey` intDataConKey
127 %************************************************************************
129 \subsection{Class predicates}
131 %************************************************************************
134 isNoDictClass, isNumericClass, isStandardClass :: Class -> Bool
136 isNumericClass clas = classKey clas `is_elem` numericClassKeys
137 isStandardClass clas = classKey clas `is_elem` standardClassKeys
138 isNoDictClass clas = classKey clas `is_elem` noDictClassKeys
139 is_elem = isIn "is_X_Class"