2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section[PrelInfo]{The @PrelInfo@ interface to the compiler's prelude knowledge}
11 wiredInNames, -- Names of wired in things
13 maybeWiredInTyConName,
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"
34 import PrelNames -- Prelude module names
36 import PrimOp ( PrimOp(..), allThePrimOps, primOpRdrName )
37 import DataCon ( DataCon, dataConId, dataConWrapId )
38 import MkId ( mkPrimOpId, wiredInIds )
39 import MkId -- All of it, for re-export
40 import TysPrim ( primTyCons )
41 import TysWiredIn ( wiredInTyCons )
42 import HscTypes ( TyThing(..) )
43 import Id ( Id, idName )
46 import RdrName ( RdrName )
47 import Name ( Name, getName )
48 import TyCon ( tyConDataConsIfAvailable, TyCon, tyConName )
49 import Class ( Class, classKey )
50 import Type ( funTyCon )
52 import BasicTypes ( Boxity(..) )
54 import Outputable ( ppr, pprPanic )
57 %************************************************************************
59 \subsection[builtinNameInfo]{Lookup built-in names}
61 %************************************************************************
63 We have two ``builtin name funs,'' one to look up @TyCons@ and
64 @Classes@, the other to look up values.
67 wiredInThings :: [TyThing]
71 map ATyCon ([funTyCon] ++ primTyCons ++ wiredInTyCons)
77 , map (AnId . mkPrimOpId) allThePrimOps
80 wiredInNames :: [Name]
81 wiredInNames = [n | thing <- wiredInThings, n <- tyThingNames thing]
83 tyThingNames :: TyThing -> [Name]
84 tyThingNames (AClass cl) = pprPanic "tyThingNames" (ppr cl) -- Not used
85 tyThingNames (AnId id) = [getName id]
86 tyThingNames (ATyCon tc)
87 = getName tc : [ getName n | dc <- tyConDataConsIfAvailable tc,
88 n <- [dataConId dc, dataConWrapId dc] ]
89 -- Synonyms return empty list of constructors
91 maybeWiredInIdName :: Name -> Maybe Id
93 = case filter ((== nm).idName) wiredInIds of
97 maybeWiredInTyConName :: Name -> Maybe TyCon
98 maybeWiredInTyConName nm
99 = case filter ((== nm).tyConName) wiredInTyCons of
104 We let a lot of "non-standard" values be visible, so that we can make
105 sense of them in interface pragmas. It's cool, though they all have
106 "non-standard" names, so they won't get past the parser in user code.
109 %************************************************************************
111 \subsection{RdrNames for the primops}
113 %************************************************************************
115 These can't be in PrelNames, because we get the RdrName from the PrimOp,
116 which is above PrelNames in the module hierarchy.
119 eqH_Char_RDR = primOpRdrName CharEqOp
120 ltH_Char_RDR = primOpRdrName CharLtOp
121 eqH_Word_RDR = primOpRdrName WordEqOp
122 ltH_Word_RDR = primOpRdrName WordLtOp
123 eqH_Addr_RDR = primOpRdrName AddrEqOp
124 ltH_Addr_RDR = primOpRdrName AddrLtOp
125 eqH_Float_RDR = primOpRdrName FloatEqOp
126 ltH_Float_RDR = primOpRdrName FloatLtOp
127 eqH_Double_RDR = primOpRdrName DoubleEqOp
128 ltH_Double_RDR = primOpRdrName DoubleLtOp
129 eqH_Int_RDR = primOpRdrName IntEqOp
130 ltH_Int_RDR = primOpRdrName IntLtOp
131 geH_RDR = primOpRdrName IntGeOp
132 leH_RDR = primOpRdrName IntLeOp
133 minusH_RDR = primOpRdrName IntSubOp
135 tagToEnumH_RDR = primOpRdrName TagToEnumOp
139 %************************************************************************
141 \subsection{Built-in keys}
143 %************************************************************************
145 ToDo: make it do the ``like'' part properly (as in 0.26 and before).
148 maybeCharLikeCon, maybeIntLikeCon :: DataCon -> Bool
149 maybeCharLikeCon con = con `hasKey` charDataConKey
150 maybeIntLikeCon con = con `hasKey` intDataConKey
154 %************************************************************************
156 \subsection{Class predicates}
158 %************************************************************************
161 isCcallishClass, isCreturnableClass, isNoDictClass,
162 isNumericClass, isStandardClass :: Class -> Bool
164 isNumericClass clas = classKey clas `is_elem` numericClassKeys
165 isStandardClass clas = classKey clas `is_elem` standardClassKeys
166 isCcallishClass clas = classKey clas `is_elem` cCallishClassKeys
167 isCreturnableClass clas = classKey clas == cReturnableClassKey
168 isNoDictClass clas = classKey clas `is_elem` noDictClassKeys
169 is_elem = isIn "is_X_Class"