2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section[PrelInfo]{The @PrelInfo@ interface to the compiler's prelude knowledge}
11 wiredInThings, -- Names of wired in things
14 cCallableClassDecl, cReturnableClassDecl, assertDecl,
17 eqH_Char_RDR, ltH_Char_RDR, eqH_Word_RDR, ltH_Word_RDR,
18 eqH_Addr_RDR, ltH_Addr_RDR, eqH_Float_RDR, ltH_Float_RDR,
19 eqH_Double_RDR, ltH_Double_RDR, eqH_Int_RDR, ltH_Int_RDR,
20 geH_RDR, leH_RDR, minusH_RDR, tagToEnumH_RDR,
22 -- Random other things
23 maybeCharLikeCon, maybeIntLikeCon,
26 isCcallishClass, isCreturnableClass, isNoDictClass,
27 isNumericClass, isStandardClass
31 #include "HsVersions.h"
33 import PrelNames -- Prelude module names
35 import PrimOp ( PrimOp(..), allThePrimOps, primOpRdrName, primOpOcc )
36 import DataCon ( DataCon )
38 import MkId ( mkPrimOpId, wiredInIds )
39 import MkId -- All of it, for re-export
40 import Name ( nameOccName, nameRdrName )
41 import RdrName ( mkRdrUnqual )
42 import HsSyn ( HsTyVarBndr(..), TyClDecl(..), HsType(..) )
43 import OccName ( mkVarOcc )
44 import TysPrim ( primTyCons )
45 import TysWiredIn ( wiredInTyCons )
46 import RdrHsSyn ( mkClassDecl )
47 import HscTypes ( TyThing(..), implicitTyThingIds, TypeEnv, mkTypeEnv,
48 GenAvailInfo(..), RdrAvailInfo )
49 import Class ( Class, classKey )
50 import Type ( funTyCon, openTypeKind, liftedTypeKind )
51 import TyCon ( tyConName )
52 import SrcLoc ( noSrcLoc )
56 %************************************************************************
58 \subsection[builtinNameInfo]{Lookup built-in names}
60 %************************************************************************
62 We have two ``builtin name funs,'' one to look up @TyCons@ and
63 @Classes@, the other to look up values.
66 wiredInThings :: [TyThing]
69 [ -- Wired in TyCons and their implicit Ids
71 , map AnId (implicitTyThingIds tycon_things)
77 , map (AnId . mkPrimOpId) allThePrimOps
80 tycon_things = map ATyCon ([funTyCon] ++ primTyCons ++ wiredInTyCons)
82 wiredInThingEnv :: TypeEnv
83 wiredInThingEnv = mkTypeEnv wiredInThings
86 We let a lot of "non-standard" values be visible, so that we can make
87 sense of them in interface pragmas. It's cool, though they all have
88 "non-standard" names, so they won't get past the parser in user code.
90 %************************************************************************
92 \subsection{Export lists for pseudo-modules (GHC.Prim)}
94 %************************************************************************
96 GHC.Prim "exports" all the primops and primitive types, some
97 wired-in Ids, and the CCallable & CReturnable classes.
100 ghcPrimExports :: [RdrAvailInfo]
101 = AvailTC cCallableOcc [ cCallableOcc ] :
102 AvailTC cReturnableOcc [ cReturnableOcc ] :
103 Avail (nameOccName assertName) : -- doesn't have an Id
104 map (Avail . nameOccName . idName) ghcPrimIds ++
105 map (Avail . primOpOcc) allThePrimOps ++
106 [ AvailTC occ [occ] |
107 n <- funTyCon : primTyCons, let occ = nameOccName (tyConName n)
110 cCallableOcc = nameOccName cCallableClassName
111 cReturnableOcc = nameOccName cReturnableClassName
115 tcdName = nameRdrName assertName,
116 tcdType = HsForAllTy (Just [liftedAlpha]) [] (HsTyVar alpha),
123 ([], nameRdrName cCallableClassName, [openAlpha])
131 ([], nameRdrName cReturnableClassName, [openAlpha])
137 alpha = mkRdrUnqual (mkVarOcc FSLIT("a"))
138 openAlpha = IfaceTyVar alpha openTypeKind
139 liftedAlpha = IfaceTyVar alpha liftedTypeKind
142 %************************************************************************
144 \subsection{RdrNames for the primops}
146 %************************************************************************
148 These can't be in PrelNames, because we get the RdrName from the PrimOp,
149 which is above PrelNames in the module hierarchy.
152 eqH_Char_RDR = primOpRdrName CharEqOp
153 ltH_Char_RDR = primOpRdrName CharLtOp
154 eqH_Word_RDR = primOpRdrName WordEqOp
155 ltH_Word_RDR = primOpRdrName WordLtOp
156 eqH_Addr_RDR = primOpRdrName AddrEqOp
157 ltH_Addr_RDR = primOpRdrName AddrLtOp
158 eqH_Float_RDR = primOpRdrName FloatEqOp
159 ltH_Float_RDR = primOpRdrName FloatLtOp
160 eqH_Double_RDR = primOpRdrName DoubleEqOp
161 ltH_Double_RDR = primOpRdrName DoubleLtOp
162 eqH_Int_RDR = primOpRdrName IntEqOp
163 ltH_Int_RDR = primOpRdrName IntLtOp
164 geH_RDR = primOpRdrName IntGeOp
165 leH_RDR = primOpRdrName IntLeOp
166 minusH_RDR = primOpRdrName IntSubOp
168 tagToEnumH_RDR = primOpRdrName TagToEnumOp
172 %************************************************************************
174 \subsection{Built-in keys}
176 %************************************************************************
178 ToDo: make it do the ``like'' part properly (as in 0.26 and before).
181 maybeCharLikeCon, maybeIntLikeCon :: DataCon -> Bool
182 maybeCharLikeCon con = con `hasKey` charDataConKey
183 maybeIntLikeCon con = con `hasKey` intDataConKey
187 %************************************************************************
189 \subsection{Class predicates}
191 %************************************************************************
194 isCcallishClass, isCreturnableClass, isNoDictClass,
195 isNumericClass, isStandardClass :: Class -> Bool
197 isNumericClass clas = classKey clas `is_elem` numericClassKeys
198 isStandardClass clas = classKey clas `is_elem` standardClassKeys
199 isCcallishClass clas = classKey clas `is_elem` cCallishClassKeys
200 isCreturnableClass clas = classKey clas == cReturnableClassKey
201 isNoDictClass clas = classKey clas `is_elem` noDictClassKeys
202 is_elem = isIn "is_X_Class"