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,
16 -- Random other things
17 maybeCharLikeCon, maybeIntLikeCon,
20 isCcallishClass, isCreturnableClass, isNoDictClass,
21 isNumericClass, isStandardClass
25 #include "HsVersions.h"
27 import PrelNames -- Prelude module names
29 import PrimOp ( allThePrimOps, primOpOcc )
30 import DataCon ( DataCon )
32 import MkId ( mkPrimOpId, wiredInIds )
33 import MkId -- All of it, for re-export
34 import Name ( nameOccName )
35 import RdrName ( mkRdrUnqual, getRdrName )
36 import HsSyn ( HsTyVarBndr(..) )
37 import OccName ( mkVarOcc )
38 import TysPrim ( primTyCons )
39 import TysWiredIn ( wiredInTyCons )
40 import RdrHsSyn ( mkClassDecl )
41 import HscTypes ( TyThing(..), implicitTyThingIds, TypeEnv, mkTypeEnv,
42 GenAvailInfo(..), RdrAvailInfo )
43 import Class ( Class, classKey )
44 import Type ( funTyCon, openTypeKind, liftedTypeKind )
45 import TyCon ( tyConName )
46 import SrcLoc ( noSrcLoc )
50 %************************************************************************
52 \subsection[builtinNameInfo]{Lookup built-in names}
54 %************************************************************************
56 We have two ``builtin name funs,'' one to look up @TyCons@ and
57 @Classes@, the other to look up values.
60 wiredInThings :: [TyThing]
63 [ -- Wired in TyCons and their implicit Ids
65 , map AnId (implicitTyThingIds tycon_things)
71 , map (AnId . mkPrimOpId) allThePrimOps
74 tycon_things = map ATyCon ([funTyCon] ++ primTyCons ++ wiredInTyCons)
76 wiredInThingEnv :: TypeEnv
77 wiredInThingEnv = mkTypeEnv wiredInThings
80 We let a lot of "non-standard" values be visible, so that we can make
81 sense of them in interface pragmas. It's cool, though they all have
82 "non-standard" names, so they won't get past the parser in user code.
84 %************************************************************************
86 \subsection{Export lists for pseudo-modules (GHC.Prim)}
88 %************************************************************************
90 GHC.Prim "exports" all the primops and primitive types, some
91 wired-in Ids, and the CCallable & CReturnable classes.
94 ghcPrimExports :: [RdrAvailInfo]
95 = AvailTC cCallableOcc [ cCallableOcc ] :
96 AvailTC cReturnableOcc [ cReturnableOcc ] :
97 map (Avail . nameOccName . idName) ghcPrimIds ++
98 map (Avail . primOpOcc) allThePrimOps ++
100 n <- funTyCon : primTyCons, let occ = nameOccName (tyConName n)
103 cCallableOcc = nameOccName cCallableClassName
104 cReturnableOcc = nameOccName cReturnableClassName
108 ([], getRdrName cCallableClassName, [openAlpha])
116 ([], getRdrName cReturnableClassName, [openAlpha])
122 alpha = mkRdrUnqual (mkVarOcc FSLIT("a"))
123 openAlpha = IfaceTyVar alpha openTypeKind
124 liftedAlpha = IfaceTyVar alpha liftedTypeKind
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 isCcallishClass, isCreturnableClass, isNoDictClass,
151 isNumericClass, isStandardClass :: Class -> Bool
153 isNumericClass clas = classKey clas `is_elem` numericClassKeys
154 isStandardClass clas = classKey clas `is_elem` standardClassKeys
155 isCcallishClass clas = classKey clas `is_elem` cCallishClassKeys
156 isCreturnableClass clas = classKey clas == cReturnableClassKey
157 isNoDictClass clas = classKey clas `is_elem` noDictClassKeys
158 is_elem = isIn "is_X_Class"