2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section[PrelInfo]{The @PrelInfo@ interface to the compiler's prelude knowledge}
15 -- Random other things
16 maybeCharLikeCon, maybeIntLikeCon,
19 isNoDictClass, isNumericClass, isStandardClass
23 #include "HsVersions.h"
25 import PrelNames ( basicKnownKeyNames,
26 hasKey, charDataConKey, intDataConKey,
27 numericClassKeys, standardClassKeys,
30 import DsMeta ( templateHaskellNames )
31 import NameSet ( nameSetToList )
34 import PrimOp ( allThePrimOps, primOpOcc )
35 import DataCon ( DataCon )
37 import MkId ( mkPrimOpId, wiredInIds )
38 import MkId -- All of it, for re-export
39 import Name ( Name, nameOccName, NamedThing(..) )
40 import RdrName ( mkRdrUnqual )
41 import HsSyn ( HsTyVarBndr(..) )
42 import OccName ( mkVarOcc )
43 import TysPrim ( primTyCons )
44 import TysWiredIn ( wiredInTyCons )
45 import HscTypes ( TyThing(..), implicitTyThings, TypeEnv, mkTypeEnv,
46 GenAvailInfo(..), RdrAvailInfo )
47 import Class ( Class, classKey, className )
48 import Type ( funTyCon, openTypeKind, liftedTypeKind )
49 import TyCon ( tyConName )
53 %************************************************************************
55 \subsection[builtinNameInfo]{Lookup built-in names}
57 %************************************************************************
59 We have two ``builtin name funs,'' one to look up @TyCons@ and
60 @Classes@, the other to look up values.
63 wiredInThings :: [TyThing]
66 [ -- Wired in TyCons and their implicit Ids
68 , implicitTyThings tycon_things
74 , map (AnId . mkPrimOpId) allThePrimOps
77 tycon_things = map ATyCon ([funTyCon] ++ primTyCons ++ wiredInTyCons)
79 wiredInThingEnv :: TypeEnv
80 wiredInThingEnv = mkTypeEnv wiredInThings
82 knownKeyNames :: [Name]
84 = map getName wiredInThings
87 ++ nameSetToList templateHaskellNames
91 We let a lot of "non-standard" values be visible, so that we can make
92 sense of them in interface pragmas. It's cool, though they all have
93 "non-standard" names, so they won't get past the parser in user code.
95 %************************************************************************
97 \subsection{Export lists for pseudo-modules (GHC.Prim)}
99 %************************************************************************
101 GHC.Prim "exports" all the primops and primitive types, some
105 ghcPrimExports :: [RdrAvailInfo]
106 = map (Avail . nameOccName . idName) ghcPrimIds ++
107 map (Avail . primOpOcc) allThePrimOps ++
108 [ AvailTC occ [occ] |
109 n <- funTyCon : primTyCons, let occ = nameOccName (tyConName n)
112 alpha = mkRdrUnqual (mkVarOcc FSLIT("a"))
113 openAlpha = IfaceTyVar alpha openTypeKind
114 liftedAlpha = IfaceTyVar alpha liftedTypeKind
118 %************************************************************************
120 \subsection{Built-in keys}
122 %************************************************************************
124 ToDo: make it do the ``like'' part properly (as in 0.26 and before).
127 maybeCharLikeCon, maybeIntLikeCon :: DataCon -> Bool
128 maybeCharLikeCon con = con `hasKey` charDataConKey
129 maybeIntLikeCon con = con `hasKey` intDataConKey
133 %************************************************************************
135 \subsection{Class predicates}
137 %************************************************************************
140 isNoDictClass, isNumericClass, isStandardClass :: Class -> Bool
142 isNumericClass clas = classKey clas `is_elem` numericClassKeys
143 isStandardClass clas = classKey clas `is_elem` standardClassKeys
144 isNoDictClass clas = classKey clas `is_elem` noDictClassKeys
145 is_elem = isIn "is_X_Class"