-- tuples
mkTupleTy,
tupleTyCon, tupleCon,
- unitTyCon, unitDataConId, pairTyCon,
+ unitTyCon, unitDataCon, unitDataConId, pairTyCon,
unboxedSingletonTyCon, unboxedSingletonDataCon,
unboxedPairTyCon, unboxedPairDataCon,
#include "HsVersions.h"
-import {-# SOURCE #-} MkId( mkDataConId, mkDataConWrapId )
+import {-# SOURCE #-} MkId( mkDataConWorkId )
import {-# SOURCE #-} Generics( mkTyConGenInfo )
-- friends:
-- others:
import Constants ( mAX_TUPLE_SIZE )
-import Module ( mkPrelModule )
-import Name ( Name, nameRdrName, nameUnique, nameOccName,
+import Module ( mkBasePkgModule )
+import Name ( Name, nameUnique, nameOccName,
nameModule, mkWiredInName )
-import OccName ( mkOccFS, tcName, dataName, mkWorkerOcc, mkGenOcc1, mkGenOcc2 )
-import RdrName ( rdrNameOcc )
+import OccName ( mkOccFS, tcName, dataName, mkDataConWorkerOcc, mkGenOcc1, mkGenOcc2 )
import DataCon ( DataCon, mkDataCon, dataConWorkId, dataConSourceArity )
import Var ( TyVar, tyVarKind )
import TyCon ( TyCon, AlgTyConFlavour(..), DataConDetails(..), tyConDataCons,
mkTupleTyCon, mkAlgTyCon, tyConName
)
-import BasicTypes ( Arity, RecFlag(..), Boxity(..), isBoxed, StrictnessMark(..) )
+import BasicTypes ( Arity, RecFlag(..), Boxity(..), isBoxed )
import Type ( Type, mkTyConTy, mkTyConApp, mkTyVarTy, mkTyVarTys,
mkArrowKinds, liftedTypeKind, unliftedTypeKind,
mkTupleDataConUnique, mkPArrDataConUnique )
import PrelNames
import Array
+import FastString
alpha_tyvar = [alphaTyVar]
alpha_ty = [alphaTy]
%* *
%************************************************************************
+If you change which things are wired in, make sure you change their
+names in PrelNames, so they use wTcQual, wDataQual, etc
+
\begin{code}
wiredInTyCons :: [TyCon]
wiredInTyCons = data_tycons ++ tuple_tycons ++ unboxed_tuple_tycons
genericTyCons :: [TyCon]
genericTyCons = [ plusTyCon, crossTyCon, genUnitTyCon ]
-
tuple_tycons = unitTyCon : [tupleTyCon Boxed i | i <- [2..mAX_TUPLE_SIZE] ]
unboxed_tuple_tycons = [tupleTyCon Unboxed i | i <- [1..mAX_TUPLE_SIZE] ]
\end{code}
name2 = mkWiredInName mod occ_name2 fn2_key
pcDataCon :: Name -> [TyVar] -> ThetaType -> [Type] -> TyCon -> DataCon
+-- The Name should be in the DataName name space; it's the name
+-- of the DataCon itself.
+--
-- The unique is the first of two free uniques;
--- the first is used for the datacon itself and the worker;
--- the second is used for the wrapper.
+-- the first is used for the datacon itself,
+-- the second is used for the "worker name"
-pcDataCon name tyvars context arg_tys tycon
+pcDataCon dc_name tyvars context arg_tys tycon
= data_con
where
- data_con = mkDataCon name
- [ NotMarkedStrict | a <- arg_tys ]
- [ {- no labelled fields -} ]
- tyvars context [] [] arg_tys tycon work_id wrap_id
-
- wrap_rdr = nameRdrName name
- wrap_occ = rdrNameOcc wrap_rdr
-
- mod = nameModule name
- wrap_id = mkDataConWrapId data_con
-
- work_occ = mkWorkerOcc wrap_occ
- work_key = incrUnique (nameUnique name)
- work_name = mkWiredInName mod work_occ work_key
- work_id = mkDataConId work_name data_con
+ data_con = mkDataCon dc_name
+ [{- No strictness -}]
+ [{- No labelled fields -}]
+ tyvars context [] [] arg_tys tycon work_id
+ Nothing {- No wrapper for wired-in things
+ (they are too simple to need one) -}
+
+ mod = nameModule dc_name
+ wrk_occ = mkDataConWorkerOcc (nameOccName dc_name)
+ wrk_key = incrUnique (nameUnique dc_name)
+ wrk_name = mkWiredInName mod wrk_occ wrk_key
+ work_id = mkDataConWorkId wrk_name data_con
\end{code}
tupleCon Unboxed i = snd (unboxedTupleArr ! i)
boxedTupleArr, unboxedTupleArr :: Array Int (TyCon,DataCon)
-boxedTupleArr = array (0,mAX_TUPLE_SIZE) [(i,mk_tuple Boxed i) | i <- [0..mAX_TUPLE_SIZE]]
-unboxedTupleArr = array (0,mAX_TUPLE_SIZE) [(i,mk_tuple Unboxed i) | i <- [0..mAX_TUPLE_SIZE]]
+boxedTupleArr = listArray (0,mAX_TUPLE_SIZE) [mk_tuple Boxed i | i <- [0..mAX_TUPLE_SIZE]]
+unboxedTupleArr = listArray (0,mAX_TUPLE_SIZE) [mk_tuple Unboxed i | i <- [0..mAX_TUPLE_SIZE]]
mk_tuple :: Boxity -> Int -> (TyCon,DataCon)
mk_tuple boxity arity = (tycon, tuple_con)
name = mkWiredInName mod (mkOccFS dataName name_str) dc_uniq
tc_uniq = mkTupleTyConUnique boxity arity
dc_uniq = mkTupleDataConUnique boxity arity
- mod = mkPrelModule mod_name
+ mod = mkBasePkgModule mod_name
gen_info = mk_tc_gen_info mod tc_uniq tc_name tycon
unitTyCon = tupleTyCon Boxed 0
-unitDataConId = dataConWorkId (head (tyConDataCons unitTyCon))
+unitDataCon = head (tyConDataCons unitTyCon)
+unitDataConId = dataConWorkId unitDataCon
pairTyCon = tupleTyCon Boxed 2
alpha_tyvar [] [mkStablePtrPrimTy alphaTy] stablePtrTyCon
\end{code}
-\begin{code}
-foreignObjTyCon
- = pcNonRecDataTyCon foreignObjTyConName
- [] [] [foreignObjDataCon]
- where
- foreignObjDataCon
- = pcDataCon foreignObjDataConName
- [] [] [foreignObjPrimTy] foreignObjTyCon
-\end{code}
-
-\begin{code}
-foreignPtrTyCon
- = pcNonRecDataTyCon foreignPtrTyConName
- alpha_tyvar [(True,False)] [foreignPtrDataCon]
- where
- foreignPtrDataCon
- = pcDataCon foreignPtrDataConName
- alpha_tyvar [] [foreignObjPrimTy] foreignPtrTyCon
-\end{code}
-
%************************************************************************
%* *
\subsection[TysWiredIn-Integer]{@Integer@ and its related ``pairing'' types}
where
tyvar = head alphaTyVars
tyvarTys = replicate arity $ mkTyVarTy tyvar
- nameStr = _PK_ ("MkPArr" ++ show arity)
+ nameStr = mkFastString ("MkPArr" ++ show arity)
name = mkWiredInName mod (mkOccFS dataName nameStr) uniq
uniq = mkPArrDataConUnique arity
- mod = mkPrelModule pREL_PARR_Name
+ mod = mkBasePkgModule pREL_PARR_Name
-- checks whether a data constructor is a fake constructor for parallel arrays
--