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,
17 -- Random other things
18 maybeCharLikeCon, maybeIntLikeCon,
21 isCcallishClass, isCreturnableClass, isNoDictClass,
22 isNumericClass, isStandardClass
26 #include "HsVersions.h"
28 import PrelNames ( basicKnownKeyNames,
29 cCallableClassName, cReturnableClassName,
30 hasKey, charDataConKey, intDataConKey,
31 numericClassKeys, standardClassKeys, cCallishClassKeys,
34 import DsMeta ( templateHaskellNames )
35 import NameSet ( nameSetToList )
38 import PrimOp ( allThePrimOps, primOpOcc )
39 import DataCon ( DataCon )
41 import MkId ( mkPrimOpId, wiredInIds )
42 import MkId -- All of it, for re-export
43 import Name ( Name, nameOccName )
44 import RdrName ( mkRdrUnqual, getRdrName )
45 import HsSyn ( HsTyVarBndr(..) )
46 import OccName ( mkVarOcc )
47 import TysPrim ( primTyCons )
48 import TysWiredIn ( wiredInTyCons )
49 import RdrHsSyn ( mkClassDecl )
50 import HscTypes ( TyThing(..), implicitTyThingIds, TypeEnv, mkTypeEnv,
51 GenAvailInfo(..), RdrAvailInfo )
52 import Class ( Class, classKey, className )
53 import Type ( funTyCon, openTypeKind, liftedTypeKind )
54 import TyCon ( tyConName )
55 import SrcLoc ( noSrcLoc )
59 %************************************************************************
61 \subsection[builtinNameInfo]{Lookup built-in names}
63 %************************************************************************
65 We have two ``builtin name funs,'' one to look up @TyCons@ and
66 @Classes@, the other to look up values.
69 wiredInThings :: [TyThing]
72 [ -- Wired in TyCons and their implicit Ids
74 , map AnId (implicitTyThingIds tycon_things)
80 , map (AnId . mkPrimOpId) allThePrimOps
83 tycon_things = map ATyCon ([funTyCon] ++ primTyCons ++ wiredInTyCons)
85 wiredInThingEnv :: TypeEnv
86 wiredInThingEnv = mkTypeEnv wiredInThings
88 knownKeyNames :: [Name]
92 ++ nameSetToList templateHaskellNames
96 We let a lot of "non-standard" values be visible, so that we can make
97 sense of them in interface pragmas. It's cool, though they all have
98 "non-standard" names, so they won't get past the parser in user code.
100 %************************************************************************
102 \subsection{Export lists for pseudo-modules (GHC.Prim)}
104 %************************************************************************
106 GHC.Prim "exports" all the primops and primitive types, some
107 wired-in Ids, and the CCallable & CReturnable classes.
110 ghcPrimExports :: [RdrAvailInfo]
111 = AvailTC cCallableOcc [ cCallableOcc ] :
112 AvailTC cReturnableOcc [ cReturnableOcc ] :
113 map (Avail . nameOccName . idName) ghcPrimIds ++
114 map (Avail . primOpOcc) allThePrimOps ++
115 [ AvailTC occ [occ] |
116 n <- funTyCon : primTyCons, let occ = nameOccName (tyConName n)
119 cCallableOcc = nameOccName cCallableClassName
120 cReturnableOcc = nameOccName cReturnableClassName
124 ([], getRdrName cCallableClassName, [openAlpha])
132 ([], getRdrName cReturnableClassName, [openAlpha])
138 alpha = mkRdrUnqual (mkVarOcc FSLIT("a"))
139 openAlpha = IfaceTyVar alpha openTypeKind
140 liftedAlpha = IfaceTyVar alpha liftedTypeKind
144 %************************************************************************
146 \subsection{Built-in keys}
148 %************************************************************************
150 ToDo: make it do the ``like'' part properly (as in 0.26 and before).
153 maybeCharLikeCon, maybeIntLikeCon :: DataCon -> Bool
154 maybeCharLikeCon con = con `hasKey` charDataConKey
155 maybeIntLikeCon con = con `hasKey` intDataConKey
159 %************************************************************************
161 \subsection{Class predicates}
163 %************************************************************************
166 isCcallishClass, isCreturnableClass, isNoDictClass,
167 isNumericClass, isStandardClass :: Class -> Bool
169 isNumericClass clas = classKey clas `is_elem` numericClassKeys
170 isStandardClass clas = classKey clas `is_elem` standardClassKeys
171 isCcallishClass clas = classKey clas `is_elem` cCallishClassKeys
172 isCreturnableClass clas = className clas == cReturnableClassName
173 isNoDictClass clas = classKey clas `is_elem` noDictClassKeys
174 is_elem = isIn "is_X_Class"