2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section[PrelInfo]{The @PrelInfo@ interface to the compiler's prelude knowledge}
8 builtinNames, -- Names of things whose *unique* must be known, but
9 -- that is all. If something is in here, you know that
10 -- if it's used at all then it's Name will be just as
11 -- it is here, unique and all. Includes all the
14 thinAirIdNames, -- Names of non-wired-in Ids that may be used out of
15 setThinAirIds, -- thin air in any compilation. If they are not wired in
16 thinAirModules, -- we must be sure to import them from some Prelude
17 -- interface file even if they are not overtly
18 -- mentioned. Subset of builtinNames.
22 derivingOccurrences, -- For a given class C, this tells what other
23 -- things are needed as a result of a
27 -- Here are the thin-air Ids themselves
29 packStringForCId, unpackCStringId, unpackCString2Id,
30 unpackCStringAppendId, unpackCStringFoldrId,
33 -- Random other things
34 main_NAME, ioTyCon_NAME,
35 deRefStablePtr_NAME, makeStablePtr_NAME,
38 maybeCharLikeCon, maybeIntLikeCon,
39 needsDataDeclCtxtClassKeys, cCallishClassKeys, cCallishTyKeys,
40 isNoDictClass, isNumericClass, isStandardClass, isCcallishClass,
41 isCreturnableClass, numericTyKeys,
43 -- RdrNames for lots of things, mainly used in derivings
44 eq_RDR, ne_RDR, le_RDR, lt_RDR, ge_RDR, gt_RDR, max_RDR, min_RDR,
45 compare_RDR, minBound_RDR, maxBound_RDR, enumFrom_RDR, enumFromTo_RDR,
46 enumFromThen_RDR, enumFromThenTo_RDR, succ_RDR, pred_RDR, fromEnum_RDR, toEnum_RDR,
47 ratioDataCon_RDR, range_RDR, index_RDR, inRange_RDR, readsPrec_RDR,
48 readList_RDR, showsPrec_RDR, showList_RDR, plus_RDR, times_RDR,
49 ltTag_RDR, eqTag_RDR, gtTag_RDR, eqH_Char_RDR, ltH_Char_RDR,
50 eqH_Word_RDR, ltH_Word_RDR, eqH_Addr_RDR, ltH_Addr_RDR, eqH_Float_RDR,
51 ltH_Float_RDR, eqH_Double_RDR, ltH_Double_RDR, eqH_Int_RDR,
52 ltH_Int_RDR, geH_RDR, leH_RDR, minusH_RDR, false_RDR, true_RDR,
53 and_RDR, not_RDR, append_RDR, map_RDR, compose_RDR, mkInt_RDR,
54 error_RDR, assertErr_RDR, dataToTagH_RDR,
55 showString_RDR, showParen_RDR, readParen_RDR, lex_RDR,
56 showSpace_RDR, showList___RDR, readList___RDR, negate_RDR,
58 numClass_RDR, fractionalClass_RDR, eqClass_RDR,
59 ccallableClass_RDR, creturnableClass_RDR,
60 monadClass_RDR, enumClass_RDR, ordClass_RDR,
63 mkTupConRdrName, mkUbxTupConRdrName
67 #include "HsVersions.h"
71 import PrelMods -- Prelude module names
72 import PrelVals -- VALUES
73 import MkId ( mkPrimitiveId )
74 import PrimOp ( PrimOp(..), allThePrimOps )
75 import DataCon ( DataCon )
76 import PrimRep ( PrimRep(..) )
77 import TysPrim -- TYPES
81 import RdrName ( RdrName, mkPreludeQual )
82 import Var ( varUnique, Id )
83 import Name ( Name, OccName, Provenance(..),
84 NameSpace, tcName, clsName, varName, dataName,
85 getName, mkGlobalName, nameRdrName, systemProvenance
87 import RdrName ( rdrNameModule, rdrNameOcc, mkSrcQual )
88 import Class ( Class, classKey )
89 import TyCon ( tyConDataCons, TyCon )
90 import Type ( funTyCon )
92 import Unique -- *Key stuff
93 import UniqFM ( UniqFM, listToUFM, lookupWithDefaultUFM )
95 import Panic ( panic )
100 %************************************************************************
102 \subsection[builtinNameInfo]{Lookup built-in names}
104 %************************************************************************
106 We have two ``builtin name funs,'' one to look up @TyCons@ and
107 @Classes@, the other to look up values.
110 builtinNames :: Bag Name
114 unionManyBags (map getTyConNames wired_in_tycons)
117 , listToBag (map getName wired_in_ids)
120 , listToBag (map (getName . mkPrimitiveId) allThePrimOps)
123 , listToBag thinAirIdNames
125 -- Other names with magic keys
126 , listToBag knownKeyNames
132 getTyConNames :: TyCon -> Bag Name
134 = getName tycon `consBag`
135 listToBag (map getName (tyConDataCons tycon))
136 -- Synonyms return empty list of constructors
139 We let a lot of "non-standard" values be visible, so that we can make
140 sense of them in interface pragmas. It's cool, though they all have
141 "non-standard" names, so they won't get past the parser in user code.
144 %************************************************************************
146 \subsection{Wired in TyCons}
148 %************************************************************************
151 wired_in_tycons = [funTyCon] ++
154 unboxed_tuple_tycons ++
166 , foreignObjPrimTyCon
168 , mutableArrayPrimTyCon
169 , mutableByteArrayPrimTyCon
174 , stableNamePrimTyCon
181 tuple_tycons = unitTyCon : [tupleTyCon i | i <- [2..37] ]
182 unboxed_tuple_tycons = [unboxedTupleTyCon i | i <- [1..37] ]
198 %************************************************************************
200 \subsection{Wired in Ids}
202 %************************************************************************
206 = [ -- These error-y things are wired in because we don't yet have
207 -- a way to express in an interface file that the result type variable
208 -- is 'open'; that is can be unified with an unboxed type
210 -- [The interface file format now carry such information, but there's
211 -- no way yet of expressing at the definition site for these error-reporting
212 -- functions that they have an 'open' result type. -- sof 1/99]
216 , iRREFUT_PAT_ERROR_ID
217 , nON_EXHAUSTIVE_GUARDS_ERROR_ID
218 , nO_METHOD_BINDING_ERROR_ID
224 -- These two can't be defined in Haskell
231 %************************************************************************
233 \subsection{Thin air entities}
235 %************************************************************************
237 These are Ids that we need to reference in various parts of the
238 system, and we'd like to pull them out of thin air rather than pass
239 them around. We'd also like to have all the IdInfo available for each
240 one: i.e. everything that gets pulled out of the interface file.
242 The solution is to generate this map of global Ids after the
243 typechecker, and assign it to a global variable. Any subsequent
244 pass may refer to the map to pull Ids out. Any invalid
245 (i.e. pre-typechecker) access to the map will result in a panic.
249 = map mkKnownKeyGlobal
251 -- Needed for converting literals to Integers (used in tidyCoreExpr)
252 (varQual pREL_BASE SLIT("addr2Integer"), addr2IntegerIdKey)
255 , (varQual pREL_PACK SLIT("packCString#"), packCStringIdKey)
256 , (varQual pREL_PACK SLIT("unpackCString#"), unpackCStringIdKey)
257 , (varQual pREL_PACK SLIT("unpackNBytes#"), unpackCString2IdKey)
258 , (varQual pREL_PACK SLIT("unpackAppendCString#"), unpackCStringAppendIdKey)
259 , (varQual pREL_PACK SLIT("unpackFoldrCString#"), unpackCStringFoldrIdKey)
261 -- Folds; introduced by desugaring list comprehensions
262 , (varQual pREL_BASE SLIT("foldr"), foldrIdKey)
265 thinAirModules = [pREL_PACK] -- See notes with RnIfaces.findAndReadIface
267 noRepIntegerIds = [addr2IntegerId]
269 noRepStrIds = [unpackCString2Id, unpackCStringId]
271 addr2IntegerId = lookupThinAirId addr2IntegerIdKey
273 packStringForCId = lookupThinAirId packCStringIdKey
274 unpackCStringId = lookupThinAirId unpackCStringIdKey
275 unpackCString2Id = lookupThinAirId unpackCString2IdKey
276 unpackCStringAppendId = lookupThinAirId unpackCStringAppendIdKey
277 unpackCStringFoldrId = lookupThinAirId unpackCStringFoldrIdKey
279 foldrId = lookupThinAirId foldrIdKey
287 thinAirIdMapRef :: IORef (UniqFM Id)
288 thinAirIdMapRef = unsafePerformIO (newIORef (panic "thinAirIdMap: still empty"))
290 setThinAirIds :: [Id] -> IO ()
291 setThinAirIds thin_air_ids
292 = writeIORef thinAirIdMapRef the_map
294 the_map = listToUFM [(varUnique id, id) | id <- thin_air_ids]
296 thinAirIdMap :: UniqFM Id
297 thinAirIdMap = unsafePerformIO (readIORef thinAirIdMapRef)
298 -- Read it just once, the first time someone tugs on thinAirIdMap
300 lookupThinAirId :: Unique -> Id
301 lookupThinAirId uniq = lookupWithDefaultUFM thinAirIdMap
302 (panic "lookupThinAirId: no mapping") uniq
306 %************************************************************************
308 \subsection{Built-in keys}
310 %************************************************************************
312 Ids, Synonyms, Classes and ClassOps with builtin keys.
315 mkKnownKeyGlobal :: (RdrName, Unique) -> Name
316 mkKnownKeyGlobal (rdr_name, uniq)
317 = mkGlobalName uniq (rdrNameModule rdr_name) (rdrNameOcc rdr_name)
320 ioTyCon_NAME = mkKnownKeyGlobal (ioTyCon_RDR, ioTyConKey)
321 main_NAME = mkKnownKeyGlobal (main_RDR, mainKey)
323 -- Operations needed when compiling FFI decls
324 bindIO_NAME = mkKnownKeyGlobal (bindIO_RDR, bindIOIdKey)
325 deRefStablePtr_NAME = mkKnownKeyGlobal (deRefStablePtr_RDR, deRefStablePtrIdKey)
326 makeStablePtr_NAME = mkKnownKeyGlobal (makeStablePtr_RDR, makeStablePtrIdKey)
328 knownKeyNames :: [Name]
330 = [main_NAME, ioTyCon_NAME]
334 -- Type constructors (synonyms especially)
335 (orderingTyCon_RDR, orderingTyConKey)
336 , (rationalTyCon_RDR, rationalTyConKey)
337 , (ratioDataCon_RDR, ratioDataConKey)
338 , (ratioTyCon_RDR, ratioTyConKey)
339 , (byteArrayTyCon_RDR, byteArrayTyConKey)
340 , (mutableByteArrayTyCon_RDR, mutableByteArrayTyConKey)
341 , (foreignObjTyCon_RDR, foreignObjTyConKey)
342 , (stablePtrTyCon_RDR, stablePtrTyConKey)
343 , (stablePtrDataCon_RDR, stablePtrDataConKey)
345 -- Classes. *Must* include:
346 -- classes that are grabbed by key (e.g., eqClassKey)
347 -- classes in "Class.standardClassKeys" (quite a few)
348 , (eqClass_RDR, eqClassKey) -- mentioned, derivable
349 , (ordClass_RDR, ordClassKey) -- derivable
350 , (boundedClass_RDR, boundedClassKey) -- derivable
351 , (numClass_RDR, numClassKey) -- mentioned, numeric
352 , (enumClass_RDR, enumClassKey) -- derivable
353 , (monadClass_RDR, monadClassKey)
354 , (monadPlusClass_RDR, monadPlusClassKey)
355 , (functorClass_RDR, functorClassKey)
356 , (showClass_RDR, showClassKey) -- derivable
357 , (realClass_RDR, realClassKey) -- numeric
358 , (integralClass_RDR, integralClassKey) -- numeric
359 , (fractionalClass_RDR, fractionalClassKey) -- numeric
360 , (floatingClass_RDR, floatingClassKey) -- numeric
361 , (realFracClass_RDR, realFracClassKey) -- numeric
362 , (realFloatClass_RDR, realFloatClassKey) -- numeric
363 , (readClass_RDR, readClassKey) -- derivable
364 , (ixClass_RDR, ixClassKey) -- derivable (but it isn't Prelude.Ix; hmmm)
365 , (ccallableClass_RDR, cCallableClassKey) -- mentioned, ccallish
366 , (creturnableClass_RDR, cReturnableClassKey) -- mentioned, ccallish
369 , (fromInt_RDR, fromIntClassOpKey)
370 , (fromInteger_RDR, fromIntegerClassOpKey)
371 , (ge_RDR, geClassOpKey)
372 , (minus_RDR, minusClassOpKey)
373 , (enumFrom_RDR, enumFromClassOpKey)
374 , (enumFromThen_RDR, enumFromThenClassOpKey)
375 , (enumFromTo_RDR, enumFromToClassOpKey)
376 , (enumFromThenTo_RDR, enumFromThenToClassOpKey)
377 , (fromEnum_RDR, fromEnumClassOpKey)
378 , (toEnum_RDR, toEnumClassOpKey)
379 , (eq_RDR, eqClassOpKey)
380 , (thenM_RDR, thenMClassOpKey)
381 , (returnM_RDR, returnMClassOpKey)
382 , (failM_RDR, failMClassOpKey)
383 , (fromRational_RDR, fromRationalClassOpKey)
385 , (deRefStablePtr_RDR, deRefStablePtrIdKey)
386 , (makeStablePtr_RDR, makeStablePtrIdKey)
387 , (bindIO_RDR, bindIOIdKey)
389 , (map_RDR, mapIdKey)
390 , (append_RDR, appendIdKey)
393 , (concat_RDR, concatIdKey)
394 , (filter_RDR, filterIdKey)
395 , (zip_RDR, zipIdKey)
397 -- FFI primitive types that are not wired-in.
398 , (int8TyCon_RDR, int8TyConKey)
399 , (int16TyCon_RDR, int16TyConKey)
400 , (int32TyCon_RDR, int32TyConKey)
401 , (int64TyCon_RDR, int64TyConKey)
402 , (word8TyCon_RDR, word8TyConKey)
403 , (word16TyCon_RDR, word16TyConKey)
404 , (word32TyCon_RDR, word32TyConKey)
405 , (word64TyCon_RDR, word64TyConKey)
408 , (otherwiseId_RDR, otherwiseIdKey)
409 , (assert_RDR, assertIdKey)
413 ToDo: make it do the ``like'' part properly (as in 0.26 and before).
416 maybeCharLikeCon, maybeIntLikeCon :: DataCon -> Bool
417 maybeCharLikeCon con = getUnique con == charDataConKey
418 maybeIntLikeCon con = getUnique con == intDataConKey
421 %************************************************************************
423 \subsection{Commonly-used RdrNames}
425 %************************************************************************
427 These RdrNames are not really "built in", but some parts of the compiler
428 (notably the deriving mechanism) need to mention their names, and it's convenient
429 to write them all down in one place.
432 prelude_primop op = nameRdrName (getName (mkPrimitiveId op))
434 main_RDR = varQual mAIN SLIT("main")
435 otherwiseId_RDR = varQual pREL_BASE SLIT("otherwise")
437 intTyCon_RDR = nameRdrName (getName intTyCon)
438 ioTyCon_RDR = tcQual pREL_IO_BASE SLIT("IO")
439 ioDataCon_RDR = dataQual pREL_IO_BASE SLIT("IO")
440 bindIO_RDR = varQual pREL_IO_BASE SLIT("bindIO")
442 orderingTyCon_RDR = tcQual pREL_BASE SLIT("Ordering")
443 rationalTyCon_RDR = tcQual pREL_NUM SLIT("Rational")
444 ratioTyCon_RDR = tcQual pREL_NUM SLIT("Ratio")
445 ratioDataCon_RDR = dataQual pREL_NUM SLIT(":%")
447 byteArrayTyCon_RDR = tcQual pREL_ARR SLIT("ByteArray")
448 mutableByteArrayTyCon_RDR = tcQual pREL_ARR SLIT("MutableByteArray")
450 foreignObjTyCon_RDR = tcQual pREL_IO_BASE SLIT("ForeignObj")
451 stablePtrTyCon_RDR = tcQual pREL_STABLE SLIT("StablePtr")
452 stablePtrDataCon_RDR = dataQual pREL_STABLE SLIT("StablePtr")
453 deRefStablePtr_RDR = varQual pREL_STABLE SLIT("deRefStablePtr")
454 makeStablePtr_RDR = varQual pREL_STABLE SLIT("makeStablePtr")
456 eqClass_RDR = clsQual pREL_BASE SLIT("Eq")
457 ordClass_RDR = clsQual pREL_BASE SLIT("Ord")
458 boundedClass_RDR = clsQual pREL_BASE SLIT("Bounded")
459 numClass_RDR = clsQual pREL_BASE SLIT("Num")
460 enumClass_RDR = clsQual pREL_BASE SLIT("Enum")
461 monadClass_RDR = clsQual pREL_BASE SLIT("Monad")
462 monadPlusClass_RDR = clsQual pREL_BASE SLIT("MonadPlus")
463 functorClass_RDR = clsQual pREL_BASE SLIT("Functor")
464 showClass_RDR = clsQual pREL_BASE SLIT("Show")
465 realClass_RDR = clsQual pREL_NUM SLIT("Real")
466 integralClass_RDR = clsQual pREL_NUM SLIT("Integral")
467 fractionalClass_RDR = clsQual pREL_NUM SLIT("Fractional")
468 floatingClass_RDR = clsQual pREL_NUM SLIT("Floating")
469 realFracClass_RDR = clsQual pREL_NUM SLIT("RealFrac")
470 realFloatClass_RDR = clsQual pREL_NUM SLIT("RealFloat")
471 readClass_RDR = clsQual pREL_READ SLIT("Read")
472 ixClass_RDR = clsQual iX SLIT("Ix")
473 ccallableClass_RDR = clsQual pREL_GHC SLIT("CCallable")
474 creturnableClass_RDR = clsQual pREL_GHC SLIT("CReturnable")
476 fromInt_RDR = varQual pREL_BASE SLIT("fromInt")
477 fromInteger_RDR = varQual pREL_BASE SLIT("fromInteger")
478 minus_RDR = varQual pREL_BASE SLIT("-")
479 succ_RDR = varQual pREL_BASE SLIT("succ")
480 pred_RDR = varQual pREL_BASE SLIT("pred")
481 toEnum_RDR = varQual pREL_BASE SLIT("toEnum")
482 fromEnum_RDR = varQual pREL_BASE SLIT("fromEnum")
483 enumFrom_RDR = varQual pREL_BASE SLIT("enumFrom")
484 enumFromTo_RDR = varQual pREL_BASE SLIT("enumFromTo")
485 enumFromThen_RDR = varQual pREL_BASE SLIT("enumFromThen")
486 enumFromThenTo_RDR = varQual pREL_BASE SLIT("enumFromThenTo")
488 thenM_RDR = varQual pREL_BASE SLIT(">>=")
489 returnM_RDR = varQual pREL_BASE SLIT("return")
490 failM_RDR = varQual pREL_BASE SLIT("fail")
492 fromRational_RDR = varQual pREL_NUM SLIT("fromRational")
493 negate_RDR = varQual pREL_BASE SLIT("negate")
494 eq_RDR = varQual pREL_BASE SLIT("==")
495 ne_RDR = varQual pREL_BASE SLIT("/=")
496 le_RDR = varQual pREL_BASE SLIT("<=")
497 lt_RDR = varQual pREL_BASE SLIT("<")
498 ge_RDR = varQual pREL_BASE SLIT(">=")
499 gt_RDR = varQual pREL_BASE SLIT(">")
500 ltTag_RDR = dataQual pREL_BASE SLIT("LT")
501 eqTag_RDR = dataQual pREL_BASE SLIT("EQ")
502 gtTag_RDR = dataQual pREL_BASE SLIT("GT")
503 max_RDR = varQual pREL_BASE SLIT("max")
504 min_RDR = varQual pREL_BASE SLIT("min")
505 compare_RDR = varQual pREL_BASE SLIT("compare")
506 minBound_RDR = varQual pREL_BASE SLIT("minBound")
507 maxBound_RDR = varQual pREL_BASE SLIT("maxBound")
508 false_RDR = dataQual pREL_BASE SLIT("False")
509 true_RDR = dataQual pREL_BASE SLIT("True")
510 and_RDR = varQual pREL_BASE SLIT("&&")
511 not_RDR = varQual pREL_BASE SLIT("not")
512 compose_RDR = varQual pREL_BASE SLIT(".")
513 append_RDR = varQual pREL_BASE SLIT("++")
514 map_RDR = varQual pREL_BASE SLIT("map")
515 concat_RDR = varQual mONAD SLIT("concat")
516 filter_RDR = varQual mONAD SLIT("filter")
517 zip_RDR = varQual pREL_LIST SLIT("zip")
519 showList___RDR = varQual pREL_BASE SLIT("showList__")
520 showsPrec_RDR = varQual pREL_BASE SLIT("showsPrec")
521 showList_RDR = varQual pREL_BASE SLIT("showList")
522 showSpace_RDR = varQual pREL_BASE SLIT("showSpace")
523 showString_RDR = varQual pREL_BASE SLIT("showString")
524 showParen_RDR = varQual pREL_BASE SLIT("showParen")
526 range_RDR = varQual iX SLIT("range")
527 index_RDR = varQual iX SLIT("index")
528 inRange_RDR = varQual iX SLIT("inRange")
530 readsPrec_RDR = varQual pREL_READ SLIT("readsPrec")
531 readList_RDR = varQual pREL_READ SLIT("readList")
532 readParen_RDR = varQual pREL_READ SLIT("readParen")
533 lex_RDR = varQual pREL_READ SLIT("lex")
534 readList___RDR = varQual pREL_READ SLIT("readList__")
536 plus_RDR = varQual pREL_BASE SLIT("+")
537 times_RDR = varQual pREL_BASE SLIT("*")
538 mkInt_RDR = dataQual pREL_BASE SLIT("I#")
540 int8TyCon_RDR = tcQual iNT SLIT("Int8")
541 int16TyCon_RDR = tcQual iNT SLIT("Int16")
542 int32TyCon_RDR = tcQual iNT SLIT("Int32")
543 int64TyCon_RDR = tcQual pREL_ADDR SLIT("Int64")
545 word8TyCon_RDR = tcQual wORD SLIT("Word8")
546 word16TyCon_RDR = tcQual wORD SLIT("Word16")
547 word32TyCon_RDR = tcQual wORD SLIT("Word32")
548 word64TyCon_RDR = tcQual pREL_ADDR SLIT("Word64")
550 error_RDR = varQual pREL_ERR SLIT("error")
551 assert_RDR = varQual pREL_GHC SLIT("assert")
552 assertErr_RDR = varQual pREL_ERR SLIT("assertError")
554 eqH_Char_RDR = prelude_primop CharEqOp
555 ltH_Char_RDR = prelude_primop CharLtOp
556 eqH_Word_RDR = prelude_primop WordEqOp
557 ltH_Word_RDR = prelude_primop WordLtOp
558 eqH_Addr_RDR = prelude_primop AddrEqOp
559 ltH_Addr_RDR = prelude_primop AddrLtOp
560 eqH_Float_RDR = prelude_primop FloatEqOp
561 ltH_Float_RDR = prelude_primop FloatLtOp
562 eqH_Double_RDR = prelude_primop DoubleEqOp
563 ltH_Double_RDR = prelude_primop DoubleLtOp
564 eqH_Int_RDR = prelude_primop IntEqOp
565 ltH_Int_RDR = prelude_primop IntLtOp
566 geH_RDR = prelude_primop IntGeOp
567 leH_RDR = prelude_primop IntLeOp
568 minusH_RDR = prelude_primop IntSubOp
569 dataToTagH_RDR = prelude_primop DataToTagOp
573 mkTupConRdrName :: Int -> RdrName
574 mkTupConRdrName arity = case mkTupNameStr arity of
575 (mod, occ) -> dataQual mod occ
577 mkUbxTupConRdrName :: Int -> RdrName
578 mkUbxTupConRdrName arity = case mkUbxTupNameStr arity of
579 (mod, occ) -> dataQual mod occ
583 %************************************************************************
585 \subsection[Class-std-groups]{Standard groups of Prelude classes}
587 %************************************************************************
589 @derivableClassKeys@ is also used in checking \tr{deriving} constructs
592 @derivingOccurrences@ maps a class name to a list of the (qualified) occurrences
593 that will be mentioned by the derived code for the class when it is later generated.
594 We don't need to put in things that are WiredIn (because they are already mapped to their
595 correct name by the @NameSupply@. The class itself, and all its class ops, is
596 already flagged as an occurrence so we don't need to mention that either.
598 @derivingOccurrences@ has an item for every derivable class, even if that item is empty,
599 because we treat lookup failure as indicating that the class is illegal in a deriving clause.
602 derivingOccurrences :: UniqFM [RdrName]
603 derivingOccurrences = listToUFM deriving_occ_info
605 derivableClassKeys = map fst deriving_occ_info
608 = [ (eqClassKey, [intTyCon_RDR, and_RDR, not_RDR])
609 , (ordClassKey, [intTyCon_RDR, compose_RDR, eqTag_RDR])
610 -- EQ (from Ordering) is needed to force in the constructors
611 -- as well as the type constructor.
612 , (enumClassKey, [intTyCon_RDR, eq_RDR, ge_RDR, and_RDR, map_RDR, plus_RDR, showsPrec_RDR, append_RDR])
613 -- The last two Enum deps are only used to produce better
614 -- error msgs for derived toEnum methods.
615 , (boundedClassKey, [intTyCon_RDR])
616 , (showClassKey, [intTyCon_RDR, numClass_RDR, ordClass_RDR, compose_RDR, showString_RDR,
617 showParen_RDR, showSpace_RDR, showList___RDR])
618 , (readClassKey, [intTyCon_RDR, numClass_RDR, ordClass_RDR, append_RDR,
619 lex_RDR, readParen_RDR, readList___RDR, thenM_RDR])
620 -- returnM (and the rest of the Monad class decl)
621 -- will be forced in as result of depending
622 -- on thenM. -- SOF 1/99
623 , (ixClassKey, [intTyCon_RDR, numClass_RDR, and_RDR, map_RDR, enumFromTo_RDR,
624 returnM_RDR, failM_RDR])
625 -- the last two are needed to force returnM, thenM and failM
626 -- in before typechecking the list(monad) comprehension
627 -- generated for derived Ix instances (range method)
628 -- of single constructor types. -- SOF 8/97
630 -- intTyCon: Practically any deriving needs Int, either for index calculations,
632 -- ordClass: really it's the methods that are actually used.
633 -- numClass: for Int literals
637 NOTE: @Eq@ and @Text@ do need to appear in @standardClasses@
638 even though every numeric class has these two as a superclass,
639 because the list of ambiguous dictionaries hasn't been simplified.
642 isCcallishClass, isCreturnableClass, isNoDictClass,
643 isNumericClass, isStandardClass :: Class -> Bool
645 isNumericClass clas = classKey clas `is_elem` numericClassKeys
646 isStandardClass clas = classKey clas `is_elem` standardClassKeys
647 isCcallishClass clas = classKey clas `is_elem` cCallishClassKeys
648 isCreturnableClass clas = classKey clas == cReturnableClassKey
649 isNoDictClass clas = classKey clas `is_elem` noDictClassKeys
650 is_elem = isIn "is_X_Class"
662 -- the strictness analyser needs to know about numeric types
663 -- (see SaAbsInt.lhs)
673 needsDataDeclCtxtClassKeys = -- see comments in TcDeriv
679 , cReturnableClassKey
682 -- Renamer always imports these data decls replete with constructors
683 -- so that desugarer can always see their constructors. Ugh!
688 , mutableByteArrayTyConKey
702 = derivableClassKeys ++ numericClassKeys ++ cCallishClassKeys
704 -- We have to have "CCallable" and "CReturnable" in the standard
705 -- classes, so that if you go...
707 -- _ccall_ foo ... 93{-numeric literal-} ...
709 -- ... it can do The Right Thing on the 93.
711 noDictClassKeys -- These classes are used only for type annotations;
712 -- they are not implemented by dictionaries, ever.
717 %************************************************************************
719 \subsection{Local helpers}
721 %************************************************************************
724 varQual = mkPreludeQual varName
725 dataQual = mkPreludeQual dataName
726 tcQual = mkPreludeQual tcName
727 clsQual = mkPreludeQual clsName