projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[project @ 1998-02-03 17:13:54 by simonm]
[ghc-hetmet.git]
/
ghc
/
compiler
/
prelude
/
TysPrim.lhs
diff --git
a/ghc/compiler/prelude/TysPrim.lhs
b/ghc/compiler/prelude/TysPrim.lhs
index
08d49a8
..
7a8796a
100644
(file)
--- a/
ghc/compiler/prelude/TysPrim.lhs
+++ b/
ghc/compiler/prelude/TysPrim.lhs
@@
-7,23
+7,19
@@
This module tracks the ``state interface'' document, ``GHC prelude:
types and operations.''
\begin{code}
types and operations.''
\begin{code}
-#include "HsVersions.h"
-
module TysPrim where
module TysPrim where
-IMP_Ubiq(){-uitous-}
+#include "HsVersions.h"
-import Kind ( mkUnboxedTypeKind, mkBoxedTypeKind, mkTypeKind, mkArrowKind )
-import Name ( mkPrimitiveName )
-import PrelMods ( gHC_BUILTINS )
+import Kind ( mkBoxedTypeKind )
+import Name ( mkWiredInTyConName )
import PrimRep ( PrimRep(..) ) -- getPrimRepInfo uses PrimRep repn
import PrimRep ( PrimRep(..) ) -- getPrimRepInfo uses PrimRep repn
-import TyCon ( mkPrimTyCon, mkDataTyCon, NewOrData(..) )
-import Type ( mkTyConTy )
+import TyCon ( mkPrimTyCon, mkDataTyCon, TyCon )
+import BasicTypes ( NewOrData(..), RecFlag(..) )
+import Type ( mkTyConApp, mkTyConTy, mkTyVarTys, Type )
import TyVar ( GenTyVar(..), alphaTyVars )
import TyVar ( GenTyVar(..), alphaTyVars )
-import Type ( applyTyCon, mkTyVarTys )
-import Usage ( usageOmega )
+import PrelMods ( pREL_GHC )
import Unique
import Unique
-
\end{code}
\begin{code}
\end{code}
\begin{code}
@@
-42,30
+38,28
@@
alphaTys = mkTyVarTys alphaTyVars
pcPrimTyCon :: Unique{-TyConKey-} -> FAST_STRING -> Int -> PrimRep -> TyCon
pcPrimTyCon key str arity primrep
pcPrimTyCon :: Unique{-TyConKey-} -> FAST_STRING -> Int -> PrimRep -> TyCon
pcPrimTyCon key str arity primrep
- = mkPrimTyCon name (mk_kind arity) primrep
+ = the_tycon
where
where
- name = mkPrimitiveName key (OrigName gHC_BUILTINS str)
-
- mk_kind 0 = mkUnboxedTypeKind
- mk_kind n = mkTypeKind `mkArrowKind` mk_kind (n-1)
+ name = mkWiredInTyConName key pREL_GHC str the_tycon
+ the_tycon = mkPrimTyCon name arity primrep
-charPrimTy = applyTyCon charPrimTyCon []
+charPrimTy = mkTyConTy charPrimTyCon
charPrimTyCon = pcPrimTyCon charPrimTyConKey SLIT("Char#") 0 CharRep
charPrimTyCon = pcPrimTyCon charPrimTyConKey SLIT("Char#") 0 CharRep
-intPrimTy = applyTyCon intPrimTyCon []
+intPrimTy = mkTyConTy intPrimTyCon
intPrimTyCon = pcPrimTyCon intPrimTyConKey SLIT("Int#") 0 IntRep
intPrimTyCon = pcPrimTyCon intPrimTyConKey SLIT("Int#") 0 IntRep
-wordPrimTy = applyTyCon wordPrimTyCon []
+wordPrimTy = mkTyConTy wordPrimTyCon
wordPrimTyCon = pcPrimTyCon wordPrimTyConKey SLIT("Word#") 0 WordRep
wordPrimTyCon = pcPrimTyCon wordPrimTyConKey SLIT("Word#") 0 WordRep
-addrPrimTy = applyTyCon addrPrimTyCon []
+addrPrimTy = mkTyConTy addrPrimTyCon
addrPrimTyCon = pcPrimTyCon addrPrimTyConKey SLIT("Addr#") 0 AddrRep
addrPrimTyCon = pcPrimTyCon addrPrimTyConKey SLIT("Addr#") 0 AddrRep
-floatPrimTy = applyTyCon floatPrimTyCon []
+floatPrimTy = mkTyConTy floatPrimTyCon
floatPrimTyCon = pcPrimTyCon floatPrimTyConKey SLIT("Float#") 0 FloatRep
floatPrimTyCon = pcPrimTyCon floatPrimTyConKey SLIT("Float#") 0 FloatRep
-doublePrimTy = applyTyCon doublePrimTyCon []
+doublePrimTy = mkTyConTy doublePrimTyCon
doublePrimTyCon = pcPrimTyCon doublePrimTyConKey SLIT("Double#") 0 DoubleRep
\end{code}
doublePrimTyCon = pcPrimTyCon doublePrimTyConKey SLIT("Double#") 0 DoubleRep
\end{code}
@@
-103,7
+97,7
@@
where s is a type variable. The only purpose of the type parameter is to
keep different state threads separate. It is represented by nothing at all.
\begin{code}
keep different state threads separate. It is represented by nothing at all.
\begin{code}
-mkStatePrimTy ty = applyTyCon statePrimTyCon [ty]
+mkStatePrimTy ty = mkTyConApp statePrimTyCon [ty]
statePrimTyCon = pcPrimTyCon statePrimTyConKey SLIT("State#") 1 VoidRep
\end{code}
statePrimTyCon = pcPrimTyCon statePrimTyConKey SLIT("State#") 1 VoidRep
\end{code}
@@
-113,17
+107,8
@@
We never manipulate values of type RealWorld; it's only used in the type
system, to parameterise State#.
\begin{code}
system, to parameterise State#.
\begin{code}
-realWorldTy = applyTyCon realWorldTyCon []
-realWorldTyCon
- = mkDataTyCon name mkBoxedTypeKind
- [{-no tyvars-}]
- [{-no context-}]
- [{-no data cons!-}] -- we tell you *nothing* about this guy
- [{-no derivings-}]
- DataType
- where
- name = mkPrimitiveName realWorldTyConKey (OrigName gHC_BUILTINS SLIT("RealWorld"))
-
+realWorldTy = mkTyConTy realWorldTyCon
+realWorldTyCon = mk_no_constr_tycon realWorldTyConKey SLIT("RealWorld")
realWorldStatePrimTy = mkStatePrimTy realWorldTy
\end{code}
realWorldStatePrimTy = mkStatePrimTy realWorldTy
\end{code}
@@
-139,17
+124,23
@@
defined in \tr{TysWiredIn.lhs}, not here.
--
-- ) It's boxed; there is only one value of this
-- type, namely "void", whose semantics is just bottom.
--
-- ) It's boxed; there is only one value of this
-- type, namely "void", whose semantics is just bottom.
-voidTy = mkTyConTy voidTyCon
-
-voidTyCon
- = mkDataTyCon name mkBoxedTypeKind
- [{-no tyvars-}]
- [{-no context-}]
- [{-no data cons!-}]
- [{-no derivings-}]
- DataType
+voidTy = mkTyConTy voidTyCon
+voidTyCon = mk_no_constr_tycon voidTyConKey SLIT("Void")
+\end{code}
+
+\begin{code}
+mk_no_constr_tycon key str
+ = the_tycon
where
where
- name = mkPrimitiveName voidTyConKey (OrigName gHC_BUILTINS SLIT("Void"))
+ name = mkWiredInTyConName key pREL_GHC str the_tycon
+ the_tycon = mkDataTyCon name mkBoxedTypeKind
+ [] -- No tyvars
+ [] -- No context
+ [] -- No constructors; we tell you *nothing* about this guy
+ [] -- No derivings
+ Nothing -- Not a dictionary
+ DataType
+ NonRecursive
\end{code}
%************************************************************************
\end{code}
%************************************************************************
@@
-167,10
+158,10
@@
mutableArrayPrimTyCon = pcPrimTyCon mutableArrayPrimTyConKey SLIT("MutableArray#
mutableByteArrayPrimTyCon = pcPrimTyCon mutableByteArrayPrimTyConKey SLIT("MutableByteArray#") 1 ByteArrayRep
mutableByteArrayPrimTyCon = pcPrimTyCon mutableByteArrayPrimTyConKey SLIT("MutableByteArray#") 1 ByteArrayRep
-mkArrayPrimTy elt = applyTyCon arrayPrimTyCon [elt]
-byteArrayPrimTy = applyTyCon byteArrayPrimTyCon []
-mkMutableArrayPrimTy s elt = applyTyCon mutableArrayPrimTyCon [s, elt]
-mkMutableByteArrayPrimTy s = applyTyCon mutableByteArrayPrimTyCon [s]
+mkArrayPrimTy elt = mkTyConApp arrayPrimTyCon [elt]
+byteArrayPrimTy = mkTyConTy byteArrayPrimTyCon
+mkMutableArrayPrimTy s elt = mkTyConApp mutableArrayPrimTyCon [s, elt]
+mkMutableByteArrayPrimTy s = mkTyConApp mutableByteArrayPrimTyCon [s]
\end{code}
%************************************************************************
\end{code}
%************************************************************************
@@
-182,7
+173,7
@@
mkMutableByteArrayPrimTy s = applyTyCon mutableByteArrayPrimTyCon [s]
\begin{code}
synchVarPrimTyCon = pcPrimTyCon synchVarPrimTyConKey SLIT("SynchVar#") 2 PtrRep
\begin{code}
synchVarPrimTyCon = pcPrimTyCon synchVarPrimTyConKey SLIT("SynchVar#") 2 PtrRep
-mkSynchVarPrimTy s elt = applyTyCon synchVarPrimTyCon [s, elt]
+mkSynchVarPrimTy s elt = mkTyConApp synchVarPrimTyCon [s, elt]
\end{code}
%************************************************************************
\end{code}
%************************************************************************
@@
-194,7
+185,7
@@
mkSynchVarPrimTy s elt = applyTyCon synchVarPrimTyCon [s, elt]
\begin{code}
stablePtrPrimTyCon = pcPrimTyCon stablePtrPrimTyConKey SLIT("StablePtr#") 1 StablePtrRep
\begin{code}
stablePtrPrimTyCon = pcPrimTyCon stablePtrPrimTyConKey SLIT("StablePtr#") 1 StablePtrRep
-mkStablePtrPrimTy ty = applyTyCon stablePtrPrimTyCon [ty]
+mkStablePtrPrimTy ty = mkTyConApp stablePtrPrimTyCon [ty]
\end{code}
%************************************************************************
\end{code}
%************************************************************************
@@
-218,6
+209,6
@@
There are no primitive operations on @ForeignObj#@s (although equality
could possibly be added?)
\begin{code}
could possibly be added?)
\begin{code}
-foreignObjPrimTy = applyTyCon foreignObjPrimTyCon []
+foreignObjPrimTy = mkTyConTy foreignObjPrimTyCon
foreignObjPrimTyCon = pcPrimTyCon foreignObjPrimTyConKey SLIT("ForeignObj#") 0 ForeignObjRep
\end{code}
foreignObjPrimTyCon = pcPrimTyCon foreignObjPrimTyConKey SLIT("ForeignObj#") 0 ForeignObjRep
\end{code}