module PrelInfo (
- pRELUDE, pRELUDE_BUILTIN, pRELUDE_CORE, pRELUDE_RATIO,
- pRELUDE_LIST, pRELUDE_TEXT,
- pRELUDE_PRIMIO, pRELUDE_IO, pRELUDE_PS,
- gLASGOW_ST, gLASGOW_MISC,
-
-- finite maps for built-in things (for the renamer and typechecker):
builtinNameInfo, BuiltinNames(..),
BuiltinKeys(..), BuiltinIdInfos(..),
- -- *odd* values that need to be reached out and grabbed:
- eRROR_ID,
- pAT_ERROR_ID,
- rEC_CON_ERROR_ID,
- rEC_UPD_ERROR_ID,
- iRREFUT_PAT_ERROR_ID,
- nON_EXHAUSTIVE_GUARDS_ERROR_ID,
- aBSENT_ERROR_ID,
- packStringForCId,
- unpackCStringId, unpackCString2Id,
- unpackCStringAppendId, unpackCStringFoldrId,
- integerZeroId, integerPlusOneId,
- integerPlusTwoId, integerMinusOneId,
-
- -----------------------------------------------------
- -- the rest of the export list is organised by *type*
- -----------------------------------------------------
-
- -- type: Bool
- boolTyCon, boolTy, falseDataCon, trueDataCon,
-
- -- types: Char#, Char, String (= [Char])
- charPrimTy, charTy, stringTy,
- charPrimTyCon, charTyCon, charDataCon,
-
- -- type: Ordering (used in deriving)
- orderingTy, ltDataCon, eqDataCon, gtDataCon,
-
- -- types: Double#, Double
- doublePrimTy, doubleTy,
- doublePrimTyCon, doubleTyCon, doubleDataCon,
-
- -- types: Float#, Float
- floatPrimTy, floatTy,
- floatPrimTyCon, floatTyCon, floatDataCon,
-
- -- types: Glasgow *primitive* arrays, sequencing and I/O
- mkPrimIoTy, -- to typecheck "mainPrimIO" & for _ccall_s
- realWorldStatePrimTy, realWorldStateTy{-boxed-},
- realWorldTy, realWorldTyCon, realWorldPrimId,
- statePrimTyCon, stateDataCon, getStatePairingConInfo,
-
- byteArrayPrimTy,
-
- -- types: Void# (only used within the compiler)
- voidPrimTy, voidPrimId,
-
- -- types: Addr#, Int#, Word#, Int
- intPrimTy, intTy, intPrimTyCon, intTyCon, intDataCon,
- wordPrimTyCon, wordPrimTy, wordTy, wordTyCon, wordDataCon,
- addrPrimTyCon, addrPrimTy, addrTy, addrTyCon, addrDataCon,
- maybeIntLikeTyCon, maybeCharLikeTyCon,
-
- -- types: Integer, Rational (= Ratio Integer)
- integerTy, rationalTy,
- integerTyCon, integerDataCon,
- rationalTyCon, ratioDataCon,
-
- -- type: Lift
- liftTyCon, liftDataCon, mkLiftTy,
-
- -- type: List
- listTyCon, mkListTy, nilDataCon, consDataCon,
-
- -- type: tuples
- mkTupleTy, unitTy,
-
- -- for compilation of List Comprehensions and foldr
- foldlId, foldrId,
- mkBuild, buildId, augmentId, appendId
-
- -- and, finally, we must put in some (abstract) data types,
- -- to make the interface self-sufficient
+ maybeCharLikeTyCon, maybeIntLikeTyCon
) where
import Ubiq
import FiniteMap ( FiniteMap, emptyFM, listToFM )
import Id ( mkTupleCon, GenId, Id(..) )
import Maybes ( catMaybes )
-import Name ( origName, nameOf )
+import Name ( moduleNamePair )
import RnHsSyn ( RnName(..) )
import TyCon ( tyConDataCons, mkFunTyCon, mkTupleTyCon, TyCon )
import Type
\begin{code}
builtinNameInfo :: ( BuiltinNames, BuiltinKeys, BuiltinIdInfos )
-type BuiltinNames = (FiniteMap FAST_STRING RnName, -- WiredIn Ids
- FiniteMap FAST_STRING RnName) -- WiredIn TyCons
+type BuiltinNames = (FiniteMap (FAST_STRING,Module) RnName, -- WiredIn Ids
+ FiniteMap (FAST_STRING,Module) RnName) -- WiredIn TyCons
-- Two maps because "[]" is in both...
-type BuiltinKeys = FiniteMap FAST_STRING (Unique, Name -> RnName)
- -- Names with known uniques
+
+type BuiltinKeys = FiniteMap (FAST_STRING,Module) (Unique, Name -> RnName)
+ -- Names with known uniques
+
type BuiltinIdInfos = UniqFM IdInfo -- Info for known unique Ids
builtinNameInfo
]
id_keys = map id_key id_keys_infos
- id_key (str, uniq, info) = (str, (uniq, RnImplicit))
+ id_key (str_mod, uniq, info) = (str_mod, (uniq, RnImplicit))
assoc_id_infos = catMaybes (map assoc_info id_keys_infos)
- assoc_info (str, uniq, Just info) = Just (uniq, info)
- assoc_info (str, uniq, Nothing) = Nothing
+ assoc_info (str_mod, uniq, Just info) = Just (uniq, info)
+ assoc_info (str_mod, uniq, Nothing) = Nothing
\end{code}
, doublePrimTyCon
, floatPrimTyCon
, intPrimTyCon
- , mallocPtrPrimTyCon
+ , foreignObjPrimTyCon
, mutableArrayPrimTyCon
, mutableByteArrayPrimTyCon
, synchVarPrimTyCon
, intTyCon
, integerTyCon
, liftTyCon
- , mallocPtrTyCon
+ , foreignObjTyCon
, ratioTyCon
, return2GMPsTyCon
, returnIntAndGMPTyCon
, stateAndDoublePrimTyCon
, stateAndFloatPrimTyCon
, stateAndIntPrimTyCon
- , stateAndMallocPtrPrimTyCon
+ , stateAndForeignObjPrimTyCon
, stateAndMutableArrayPrimTyCon
, stateAndMutableByteArrayPrimTyCon
, stateAndSynchVarPrimTyCon
, stTyCon
, stringTyCon
]
-
-pcTyConWiredInInfo :: TyCon -> (FAST_STRING, RnName)
-pcTyConWiredInInfo tc = (nameOf (origName tc), WiredInTyCon tc)
-
-pcDataConWiredInInfo :: TyCon -> [(FAST_STRING, RnName)]
-pcDataConWiredInInfo tycon
- = [ (nameOf (origName con), WiredInId con) | con <- tyConDataCons tycon ]
\end{code}
The WiredIn Ids ...
else
[ parId
, forkId
-#ifdef GRAN
- , parLocalId
+ , copyableId
+ , noFollowId
+ , parAtAbsId
+ , parAtForNowId
+ , parAtId
+ , parAtRelId
, parGlobalId
- -- Add later:
- -- ,parAtId
- -- ,parAtForNowId
- -- ,copyableId
- -- ,noFollowId
-#endif {-GRAN-}
+ , parLocalId
]
-pcIdWiredInInfo :: Id -> (FAST_STRING, RnName)
-pcIdWiredInInfo id = (nameOf (origName id), WiredInId id)
+
+pcTyConWiredInInfo :: TyCon -> ((FAST_STRING,Module), RnName)
+pcTyConWiredInInfo tc = (swap (moduleNamePair tc), WiredInTyCon tc)
+
+pcDataConWiredInInfo :: TyCon -> [((FAST_STRING,Module), RnName)]
+pcDataConWiredInInfo tycon
+ = [ (swap (moduleNamePair con), WiredInId con) | con <- tyConDataCons tycon ]
+
+pcIdWiredInInfo :: Id -> ((FAST_STRING,Module), RnName)
+pcIdWiredInInfo id = (swap (moduleNamePair id), WiredInId id)
+
+swap (x,y) = (y,x)
\end{code}
WiredIn primitive numeric operations ...
\begin{code}
primop_ids
- = map primOpNameInfo allThePrimOps ++ map fn funny_name_primops
+ = map prim_fn allThePrimOps ++ map funny_fn funny_name_primops
where
- fn (op,s) = case (primOpNameInfo op) of (_,n) -> (s,n)
+ prim_fn op = case (primOpNameInfo op) of (s,n) -> ((s,pRELUDE),n)
+ funny_fn (op,s) = case (primOpNameInfo op) of (_,n) -> ((s,pRELUDE),n)
funny_name_primops
= [ (IntAddOp, SLIT("+#"))
Ids, Synonyms, Classes and ClassOps with builtin keys.
For the Ids we may also have some builtin IdInfo.
\begin{code}
-id_keys_infos :: [(FAST_STRING, Unique, Maybe IdInfo)]
+id_keys_infos :: [((FAST_STRING,Module), Unique, Maybe IdInfo)]
id_keys_infos
- = [ (SLIT("main"), mainIdKey, Nothing)
- , (SLIT("mainPrimIO"), mainPrimIOIdKey, Nothing)
+ = [ ((SLIT("main"),SLIT("Main")), mainIdKey, Nothing)
+ , ((SLIT("mainPrimIO"),SLIT("Main")), mainPrimIOIdKey, Nothing)
]
tysyn_keys
- = [ (SLIT("IO"), (iOTyConKey, RnImplicitTyCon))
+ = [ ((SLIT("IO"),pRELUDE), (iOTyConKey, RnImplicitTyCon))
]
-- this "class_keys" list *must* include:
-- classes in "Class.standardClassKeys" (quite a few)
class_keys
- = [ (s, (k, RnImplicitClass)) | (s,k) <-
- [ (SLIT("Eq"), eqClassKey) -- mentioned, derivable
- , (SLIT("Ord"), ordClassKey) -- derivable
- , (SLIT("Num"), numClassKey) -- mentioned, numeric
- , (SLIT("Real"), realClassKey) -- numeric
- , (SLIT("Integral"), integralClassKey) -- numeric
- , (SLIT("Fractional"), fractionalClassKey) -- numeric
- , (SLIT("Floating"), floatingClassKey) -- numeric
- , (SLIT("RealFrac"), realFracClassKey) -- numeric
- , (SLIT("RealFloat"), realFloatClassKey) -- numeric
--- , (SLIT("Ix"), ixClassKey) -- derivable (but it isn't Prelude.Ix; hmmm)
- , (SLIT("Bounded"), boundedClassKey) -- derivable
- , (SLIT("Enum"), enumClassKey) -- derivable
- , (SLIT("Show"), showClassKey) -- derivable
- , (SLIT("Read"), readClassKey) -- derivable
- , (SLIT("Monad"), monadClassKey)
- , (SLIT("MonadZero"), monadZeroClassKey)
- , (SLIT("MonadPlus"), monadPlusClassKey)
- , (SLIT("Functor"), functorClassKey)
- , (SLIT("CCallable"), cCallableClassKey) -- mentioned, ccallish
- , (SLIT("CReturnable"), cReturnableClassKey) -- mentioned, ccallish
+ = [ (str_mod, (k, RnImplicitClass)) | (str_mod,k) <-
+ [ ((SLIT("Eq"),pRELUDE), eqClassKey) -- mentioned, derivable
+ , ((SLIT("Eval"),pRELUDE), evalClassKey) -- mentioned
+ , ((SLIT("Ord"),pRELUDE), ordClassKey) -- derivable
+ , ((SLIT("Num"),pRELUDE), numClassKey) -- mentioned, numeric
+ , ((SLIT("Real"),pRELUDE), realClassKey) -- numeric
+ , ((SLIT("Integral"),pRELUDE), integralClassKey) -- numeric
+ , ((SLIT("Fractional"),pRELUDE), fractionalClassKey) -- numeric
+ , ((SLIT("Floating"),pRELUDE), floatingClassKey) -- numeric
+ , ((SLIT("RealFrac"),pRELUDE), realFracClassKey) -- numeric
+ , ((SLIT("RealFloat"),pRELUDE), realFloatClassKey) -- numeric
+ , ((SLIT("Ix"),iX), ixClassKey) -- derivable (but it isn't Prelude.Ix; hmmm)
+ , ((SLIT("Bounded"),pRELUDE), boundedClassKey) -- derivable
+ , ((SLIT("Enum"),pRELUDE), enumClassKey) -- derivable
+ , ((SLIT("Show"),pRELUDE), showClassKey) -- derivable
+ , ((SLIT("Read"),pRELUDE), readClassKey) -- derivable
+ , ((SLIT("Monad"),pRELUDE), monadClassKey)
+ , ((SLIT("MonadZero"),pRELUDE), monadZeroClassKey)
+ , ((SLIT("MonadPlus"),pRELUDE), monadPlusClassKey)
+ , ((SLIT("Functor"),pRELUDE), functorClassKey)
+ , ((SLIT("CCallable"),pRELUDE), cCallableClassKey) -- mentioned, ccallish
+ , ((SLIT("CReturnable"),pRELUDE), cReturnableClassKey) -- mentioned, ccallish
]]
class_op_keys
- = [ (s, (k, RnImplicit)) | (s,k) <-
- [ (SLIT("fromInt"), fromIntClassOpKey)
- , (SLIT("fromInteger"), fromIntegerClassOpKey)
- , (SLIT("fromRational"), fromRationalClassOpKey)
- , (SLIT("enumFrom"), enumFromClassOpKey)
- , (SLIT("enumFromThen"), enumFromThenClassOpKey)
- , (SLIT("enumFromTo"), enumFromToClassOpKey)
- , (SLIT("enumFromThenTo"), enumFromThenToClassOpKey)
- , (SLIT("=="), eqClassOpKey)
+ = [ (str_mod, (k, RnImplicit)) | (str_mod,k) <-
+ [ ((SLIT("fromInt"),pRELUDE), fromIntClassOpKey)
+ , ((SLIT("fromInteger"),pRELUDE), fromIntegerClassOpKey)
+ , ((SLIT("fromRational"),pRELUDE), fromRationalClassOpKey)
+ , ((SLIT("enumFrom"),pRELUDE), enumFromClassOpKey)
+ , ((SLIT("enumFromThen"),pRELUDE), enumFromThenClassOpKey)
+ , ((SLIT("enumFromTo"),pRELUDE), enumFromToClassOpKey)
+ , ((SLIT("enumFromThenTo"),pRELUDE),enumFromThenToClassOpKey)
+ , ((SLIT("=="),pRELUDE), eqClassOpKey)
]]
\end{code}