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
15 eqH_Char_RDR, ltH_Char_RDR, eqH_Word_RDR, ltH_Word_RDR,
16 eqH_Addr_RDR, ltH_Addr_RDR, eqH_Float_RDR, ltH_Float_RDR,
17 eqH_Double_RDR, ltH_Double_RDR, eqH_Int_RDR, ltH_Int_RDR,
18 geH_RDR, leH_RDR, minusH_RDR, tagToEnumH_RDR,
20 -- Random other things
21 maybeCharLikeCon, maybeIntLikeCon,
24 isCcallishClass, isCreturnableClass, isNoDictClass,
25 isNumericClass, isStandardClass
29 #include "HsVersions.h"
32 import PrelNames -- Prelude module names
34 import PrimOp ( PrimOp(..), allThePrimOps, primOpRdrName )
35 import DataCon ( DataCon, dataConId, dataConWrapId )
36 import MkId ( mkPrimOpId, wiredInIds )
37 import MkId -- All of it, for re-export
38 import TysPrim ( primTyCons )
39 import TysWiredIn ( wiredInTyCons )
40 import HscTypes ( TyThing(..) )
43 import Name ( getName, NameEnv, mkNameEnv )
44 import TyCon ( tyConDataConsIfAvailable, TyCon )
45 import Class ( Class, classKey )
46 import Type ( funTyCon )
48 import Outputable ( ppr, pprPanic )
51 %************************************************************************
53 \subsection[builtinNameInfo]{Lookup built-in names}
55 %************************************************************************
57 We have two ``builtin name funs,'' one to look up @TyCons@ and
58 @Classes@, the other to look up values.
61 wiredInThings :: [TyThing]
65 concat (map wiredInTyConThings ([funTyCon] ++ primTyCons ++ wiredInTyCons))
71 , map (AnId . mkPrimOpId) allThePrimOps
74 wiredInTyConThings :: TyCon -> [TyThing]
76 = ATyCon tc : [ AnId n | dc <- tyConDataConsIfAvailable tc,
77 n <- [dataConId dc, dataConWrapId dc] ]
78 -- Synonyms return empty list of constructors
80 wiredInThingEnv :: NameEnv TyThing
81 wiredInThingEnv = mkNameEnv [ (getName thing, thing) | thing <- wiredInThings ]
84 We let a lot of "non-standard" values be visible, so that we can make
85 sense of them in interface pragmas. It's cool, though they all have
86 "non-standard" names, so they won't get past the parser in user code.
89 %************************************************************************
91 \subsection{RdrNames for the primops}
93 %************************************************************************
95 These can't be in PrelNames, because we get the RdrName from the PrimOp,
96 which is above PrelNames in the module hierarchy.
99 eqH_Char_RDR = primOpRdrName CharEqOp
100 ltH_Char_RDR = primOpRdrName CharLtOp
101 eqH_Word_RDR = primOpRdrName WordEqOp
102 ltH_Word_RDR = primOpRdrName WordLtOp
103 eqH_Addr_RDR = primOpRdrName AddrEqOp
104 ltH_Addr_RDR = primOpRdrName AddrLtOp
105 eqH_Float_RDR = primOpRdrName FloatEqOp
106 ltH_Float_RDR = primOpRdrName FloatLtOp
107 eqH_Double_RDR = primOpRdrName DoubleEqOp
108 ltH_Double_RDR = primOpRdrName DoubleLtOp
109 eqH_Int_RDR = primOpRdrName IntEqOp
110 ltH_Int_RDR = primOpRdrName IntLtOp
111 geH_RDR = primOpRdrName IntGeOp
112 leH_RDR = primOpRdrName IntLeOp
113 minusH_RDR = primOpRdrName IntSubOp
115 tagToEnumH_RDR = primOpRdrName TagToEnumOp
119 %************************************************************************
121 \subsection{Built-in keys}
123 %************************************************************************
125 ToDo: make it do the ``like'' part properly (as in 0.26 and before).
128 maybeCharLikeCon, maybeIntLikeCon :: DataCon -> Bool
129 maybeCharLikeCon con = con `hasKey` charDataConKey
130 maybeIntLikeCon con = con `hasKey` intDataConKey
134 %************************************************************************
136 \subsection{Class predicates}
138 %************************************************************************
141 isCcallishClass, isCreturnableClass, isNoDictClass,
142 isNumericClass, isStandardClass :: Class -> Bool
144 isNumericClass clas = classKey clas `is_elem` numericClassKeys
145 isStandardClass clas = classKey clas `is_elem` standardClassKeys
146 isCcallishClass clas = classKey clas `is_elem` cCallishClassKeys
147 isCreturnableClass clas = classKey clas == cReturnableClassKey
148 isNoDictClass clas = classKey clas `is_elem` noDictClassKeys
149 is_elem = isIn "is_X_Class"