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(..), TypeEnv, mkTypeEnv )
43 import TyCon ( tyConDataConsIfAvailable, TyCon )
44 import Class ( Class, classKey )
45 import Type ( funTyCon )
49 %************************************************************************
51 \subsection[builtinNameInfo]{Lookup built-in names}
53 %************************************************************************
55 We have two ``builtin name funs,'' one to look up @TyCons@ and
56 @Classes@, the other to look up values.
59 wiredInThings :: [TyThing]
63 concat (map wiredInTyConThings ([funTyCon] ++ primTyCons ++ wiredInTyCons))
69 , map (AnId . mkPrimOpId) allThePrimOps
72 wiredInTyConThings :: TyCon -> [TyThing]
74 = ATyCon tc : [ AnId n | dc <- tyConDataConsIfAvailable tc,
75 n <- [dataConId dc, dataConWrapId dc] ]
76 -- Synonyms return empty list of constructors
78 wiredInThingEnv :: TypeEnv
79 wiredInThingEnv = mkTypeEnv wiredInThings
82 We let a lot of "non-standard" values be visible, so that we can make
83 sense of them in interface pragmas. It's cool, though they all have
84 "non-standard" names, so they won't get past the parser in user code.
87 %************************************************************************
89 \subsection{RdrNames for the primops}
91 %************************************************************************
93 These can't be in PrelNames, because we get the RdrName from the PrimOp,
94 which is above PrelNames in the module hierarchy.
97 eqH_Char_RDR = primOpRdrName CharEqOp
98 ltH_Char_RDR = primOpRdrName CharLtOp
99 eqH_Word_RDR = primOpRdrName WordEqOp
100 ltH_Word_RDR = primOpRdrName WordLtOp
101 eqH_Addr_RDR = primOpRdrName AddrEqOp
102 ltH_Addr_RDR = primOpRdrName AddrLtOp
103 eqH_Float_RDR = primOpRdrName FloatEqOp
104 ltH_Float_RDR = primOpRdrName FloatLtOp
105 eqH_Double_RDR = primOpRdrName DoubleEqOp
106 ltH_Double_RDR = primOpRdrName DoubleLtOp
107 eqH_Int_RDR = primOpRdrName IntEqOp
108 ltH_Int_RDR = primOpRdrName IntLtOp
109 geH_RDR = primOpRdrName IntGeOp
110 leH_RDR = primOpRdrName IntLeOp
111 minusH_RDR = primOpRdrName IntSubOp
113 tagToEnumH_RDR = primOpRdrName TagToEnumOp
117 %************************************************************************
119 \subsection{Built-in keys}
121 %************************************************************************
123 ToDo: make it do the ``like'' part properly (as in 0.26 and before).
126 maybeCharLikeCon, maybeIntLikeCon :: DataCon -> Bool
127 maybeCharLikeCon con = con `hasKey` charDataConKey
128 maybeIntLikeCon con = con `hasKey` intDataConKey
132 %************************************************************************
134 \subsection{Class predicates}
136 %************************************************************************
139 isCcallishClass, isCreturnableClass, isNoDictClass,
140 isNumericClass, isStandardClass :: Class -> Bool
142 isNumericClass clas = classKey clas `is_elem` numericClassKeys
143 isStandardClass clas = classKey clas `is_elem` standardClassKeys
144 isCcallishClass clas = classKey clas `is_elem` cCallishClassKeys
145 isCreturnableClass clas = classKey clas == cReturnableClassKey
146 isNoDictClass clas = classKey clas `is_elem` noDictClassKeys
147 is_elem = isIn "is_X_Class"