Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
9484be7a
Commit
9484be7a
authored
Jul 31, 2008
by
batterseapower
Browse files
Document TyCon
parent
1fa25d26
Changes
1
Show whitespace changes
Inline
Sidebyside
compiler/types/TyCon.lhs
View file @
9484be7a
...
...
@@ 7,36 +7,14 @@ The @TyCon@ datatype
\begin{code}
module TyCon(
 * Main TyCon data types
TyCon, FieldLabel,
PrimRep(..),
tyConPrimRep,
primRepSizeW,
AlgTyConRhs(..), visibleDataCons,
TyConParent(..),
SynTyConRhs(..),
isFunTyCon, isUnLiftedTyCon, isProductTyCon,
isAlgTyCon, isDataTyCon,
isNewTyCon, unwrapNewTyCon_maybe,
isSynTyCon, isClosedSynTyCon, isOpenSynTyCon,
isPrimTyCon,
isEnumerationTyCon, isGadtSyntaxTyCon, isOpenTyCon,
assocTyConArgPoss_maybe, isTyConAssoc, setTyConArgPoss,
isTupleTyCon, isUnboxedTupleTyCon, isBoxedTupleTyCon, tupleTyConBoxity,
isRecursiveTyCon, newTyConRhs, newTyConEtadRhs, newTyConCo_maybe,
isHiBootTyCon, isSuperKindTyCon,
isCoercionTyCon_maybe, isCoercionTyCon,
isImplicitTyCon,
tcExpandTyCon_maybe, coreExpandTyCon_maybe,
makeTyConAbstract, isAbstractTyCon,
mkForeignTyCon, isForeignTyCon,
 ** Constructing TyCons
mkAlgTyCon,
mkClassTyCon,
mkFunTyCon,
...
...
@@ 47,24 +25,57 @@ module TyCon(
mkSynTyCon,
mkSuperKindTyCon,
mkCoercionTyCon,
mkForeignTyCon,
 ** Predicates on TyCons
isAlgTyCon,
isClassTyCon, isFamInstTyCon,
isFunTyCon,
isPrimTyCon,
isTupleTyCon, isUnboxedTupleTyCon, isBoxedTupleTyCon,
isSynTyCon, isClosedSynTyCon, isOpenSynTyCon,
isSuperKindTyCon,
isCoercionTyCon, isCoercionTyCon_maybe,
isForeignTyCon,
isDataTyCon, isProductTyCon, isEnumerationTyCon,
isNewTyCon, isAbstractTyCon, isOpenTyCon,
isUnLiftedTyCon,
isGadtSyntaxTyCon,
isTyConAssoc,
isRecursiveTyCon,
isHiBootTyCon,
isImplicitTyCon, tyConHasGenerics,
 ** Extracting information out of TyCons
tyConName,
tyConKind,
tyConUnique,
tyConTyVars,
algTyConRhs, tyConDataCons, tyConDataCons_maybe, tyConFamilySize,
tyConDataCons, tyConDataCons_maybe, tyConSingleDataCon_maybe,
tyConFamilySize,
tyConSelIds,
tyConStupidTheta,
tyConArity,
isClassTyCon,
tyConClass_maybe,
isFamInstTyCon,
tyConFamInst_maybe, tyConFamilyCoercion_maybe,
tyConClass_maybe,
tyConFamInst_maybe, tyConFamilyCoercion_maybe,
synTyConDefn, synTyConRhs, synTyConType, synTyConResKind,
tyConExtName,  External name for foreign types
algTyConRhs,
newTyConRhs, newTyConEtadRhs, unwrapNewTyCon_maybe,
assocTyConArgPoss_maybe,
tupleTyConBoxity,
tyConSingleDataCon_maybe,
 ** Manipulating TyCons
tcExpandTyCon_maybe, coreExpandTyCon_maybe,
makeTyConAbstract,
newTyConCo_maybe,
setTyConArgPoss,
 Generics
tyConHasGenerics
 * Primitive representations of Types
PrimRep(..),
tyConPrimRep,
primRepSizeW
) where
#include "HsVersions.h"
...
...
@@ 90,51 +101,71 @@ import Constants
%************************************************************************
\begin{code}
  Represents type constructors. Type constructors are introduced by things such as:

 1) Data declarations: @data Foo = ...@ creates the @Foo@ type constructor of kind @*@

 2) Type synonyms: @type Foo = ...@ creates the @Foo@ type constructor

 3) Newtypes: @newtype Foo a = MkFoo ...@ creates the @Foo@ type constructor of kind @* > *@

 4) Class declarations: @class Foo where@ creates the @Foo@ type constructor of kind @*@

 5) Type coercions! This is because we represent a coercion from @t1@ to @t2@ as a 'Type', where
 that type has kind @t1 :=: t2@. See "Coercion" for more on this

 This data type also encodes a number of primitive, built in type constructors such as those
 for function and tuple types.
data TyCon
= FunTyCon {
=   The function type constructor, @(>)@
FunTyCon {
tyConUnique :: Unique,
tyConName :: Name,
tyConKind :: Kind,
tyConArity :: Arity
}

Al
gTyCon {  Data type, and newtype decls
.
 All lifted, all boxed
  Algebraic type constructors, which are defined to be those arising @data@ type and @newtype@ declarations.

Al
l these constructors are lifted and boxed. See 'AlgTyConRhs' for more information
.
 AlgTyCon {
tyConUnique :: Unique,
tyConName :: Name,
tyConKind :: Kind,
tyConArity :: Arity,
tyConTyVars :: [TyVar],  Scopes over (a) the algTcStupidTheta
 (b) the cached types in
 algTyConRhs.NewTyCon
 (c) the family instance
 types if present
 But not over the data constructors
tyConTyVars :: [TyVar],  ^ The type variables used in the type constructor.
 Precisely, this list scopes over:

 1. The 'algTcStupidTheta'

 2. The cached types in 'algTyConRhs.NewTyCon'

 3. The family instance types if present

 Note that it does /not/ scope over the data constructors.
algTcSelIds :: [Id], 
Its
record selectors
(empty if none
)
algTcSelIds :: [Id], 
^ The
record selectors
of this type (possibly emptys
)
algTcGadtSyntax :: Bool, 
True <=>
the data type
was
declared
using
GADT syntax

T
hat doesn't mean it's a true GADT; only that the "where"
algTcGadtSyntax :: Bool, 
^ Was
the data type declared
with
GADT syntax
? If so,

t
hat doesn't mean it's a true GADT; only that the "where"
 form was used. This field is used only to guide
 prettyprintinng
algTcStupidTheta :: [PredType],  The "stupid theta" for the data type
 (always empty for GADTs)
 prettyprinting
algTcStupidTheta :: [PredType],  ^ The \"stupid theta\" for the data type (always empty for GADTs).
 A \"stupid theta\" is the context to the left of an algebraic type
 declaration, e.g. @Eq a@ in the declaration @data Eq a => T a ...@.
algTcRhs :: AlgTyConRhs, 
Data constructors in her
e
algTcRhs :: AlgTyConRhs, 
^ Contains information about the data constructors of the algebraic typ
e
algTcRec :: RecFlag,  Tells whether the data type is part
 of a mutuallyrecursive group or not
algTcRec :: RecFlag,  ^ Tells us whether the data type is part of a mutuallyrecursive group or not
hasGenerics :: Bool, 
True <=> generic
to/from functions are
available
 (
in the exports of the data type's source module
)
hasGenerics :: Bool, 
^ Whether generic (in the XGenerics sense)
to/from functions are
 available
in the exports of the data type's source module
.
algTcParent :: TyConParent  Gives the class or family tycon for
 derived tycons representing classes
 or family instances, respectively.
algTcParent :: TyConParent  ^ Gives the class or family declaration 'TyCon' for derived 'TyCon's
 representing class or family instances, respectively. See also 'synTcParent'
}
  Represents the infinite family of tuple type constructors, @()@, @(a,b)@, @(# a, b #)@ etc.
 TupleTyCon {
tyConUnique :: Unique,
tyConName :: Name,
...
...
@@ 142,10 +173,11 @@ data TyCon
tyConArity :: Arity,
tyConBoxed :: Boxity,
tyConTyVars :: [TyVar],
dataCon :: DataCon,
dataCon :: DataCon,
 ^ Corresponding tuple data constructor
hasGenerics :: Bool
}
  Represents type synonyms
 SynTyCon {
tyConUnique :: Unique,
tyConName :: Name,
...
...
@@ 154,17 +186,15 @@ data TyCon
tyConTyVars :: [TyVar],  Bound tyvars
synTcRhs :: SynTyConRhs, 
Expanded type in here
synTcRhs :: SynTyConRhs, 
^ Contains information about the expansion of the synonym
synTcParent :: TyConParent  Gives the family tycon of
 representation tycons of family
 instances
synTcParent :: TyConParent  ^ Gives the family declaration 'TyCon' of 'TyCon's representing family instances
}
 PrimTyCon {
 Primitive types; cannot be defined in Haskell
 Now include
s foreignimported types
 Also includes Kinds


Primitive types; cannot be defined in Haskell
. This includes the usual suspects (such as @Int#@)
 as well a
s foreignimported types
and kinds
 PrimTyCon {
tyConUnique :: Unique,
tyConName :: Name,
tyConKind :: Kind,
...
...
@@ 172,119 +202,155 @@ data TyCon
 of the arity of a primtycon is!
primTyConRep :: PrimRep,
 Many primitive tycons are unboxed, but some are
 boxed (represented by pointers). The CgRep tells.
 ^ Many primitive tycons are unboxed, but some are
 boxed (represented by pointers). This 'PrimRep' holds
 that information
isUnLifted :: Bool,  Most primitive tycons are unlifted
,
 but foreignimported ones may
not be
tyConExtName :: Maybe FastString  Just
xx
for foreignimported types
isUnLifted :: Bool, 
^
Most primitive tycons are unlifted
(may not contain bottom)
 but foreignimported ones may
be lifted
tyConExtName :: Maybe FastString 
^ @
Just
e@
for foreignimported types
, holds the name of the imported thing
}
 CoercionTyCon {  E.g.
(:=:), sym, trans, left
,
right
  Type coercions, such as @
(:=:)
@
,
@
sym
@
,
@
trans
@
,
@
left
@ and @
right
@.
 INVARIANT: coercions are always fully applied
 CoercionTyCon {
tyConUnique :: Unique,
tyConName :: Name,
tyConArity :: Arity,
coKindFun :: [Type] > (Type,Type)
}  INVARIANT: coKindFun is always applied to exactly 'arity' args
 E.g. for trans (c1 :: ta=tb) (c2 :: tb=tc), the coKindFun returns
 the kind as a pair of types: (ta,tc)
 ^ Function that when given a list of the type arguments to the 'TyCon'
 constructs the types that the resulting coercion relates.

 INVARIANT: 'coKindFun' is always applied to exactly 'tyConArity' args
 E.g. for @trans (c1 :: ta=tb) (c2 :: tb=tc)@, the 'coKindFun' returns
 the kind as a pair of types: @(ta, tc)@
}
 SuperKindTyCon {  Super Kinds, TY (box) and CO (diamond).
 They have no kind; and arity zero
  Superkinds. These are "kindsofkinds" and are never seen in Haskell source programs.
 There are only two superkinds: TY (aka "box"), which is the superkind of kinds that
 construct types eventually, and CO (aka "diamond"), which is the superkind of kinds
 that just represent coercions.

 Superkinds have no kind themselves, and have arity zero
 SuperKindTyCon {
tyConUnique :: Unique,
tyConName :: Name
}
  Names of the fields in an algebraic record type
type FieldLabel = Name
 Right hand sides of type constructors for algebraic types

  Represents righthandsides of 'TyCon's for algebraic types
data AlgTyConRhs
 We know nothing about this data type, except that it's represented by a
 pointer. Used when we export a data type abstractly into an hi file.

  Says that we know nothing about this data type, except that it's represented
 by a pointer. Used when we export a data type abstractly into an .hi file.
= AbstractTyCon

The constructor r
epresents an open family without a fixed right hand

 R
epresents an open
type
family without a fixed right hand
 side. Additional instances can appear at any time.

 These are introduced by either a top level decl:
 data T a :: *
 or an assoicated data type decl, in a class decl:
 class C a b where
 data T b :: *
 These are introduced by either a top level declaration:

 > data T a :: *

 Or an assoicated data type declaration, within a class declaration:

 > class C a b where
 > data T b :: *
 OpenTyCon {
otArgPoss :: Maybe [Int]
 Nothing <=> toplevel indexed type family
 Just ns <=> associated (not toplevel) family
 In the latter case, for each tyvar in the AT decl, 'ns' gives the
 position of that tyvar in the class argument list (starting from 0).
 NB: Length is less than tyConArity iff higher kind signature.
 ^ @Nothing@ iff this is a toplevel indexed type family.
 @Just ns@ iff this is an associated (not toplevel) family

 In the latter case, for each 'TyVar' in the associated type declaration,
 @ns@ gives the position of that tyvar in the class argument list (starting
 from 0).

 NB: The length of this list is less than the accompanying 'tyConArity' iff
 we have a higher kind signature.
}
  Information about those 'TyCon's derived from a @data@ declaration. This includes
 data types with no constructors at all.
 DataTyCon {
data_cons :: [DataCon],

Th
e constructors; can be empty if the user declares

^ The data typ
e constructors; can be empty if the user declares
 the type to have no constructors
 INVARIANT: Kept in order of increasing tag

 INVARIANT: Kept in order of increasing 'DataCon' tag
 (see the tag assignment in DataCon.mkDataCon)
is_enum :: Bool  Cached
: True <=>
an enumeration type
}
 Includes data types with no constructors.
is_enum :: Bool 
^
Cached
value: is this
an enumeration type
? (See 'isEnumerationTyCon')
}
  Information about those 'TyCon's derived from a @newtype@ declaration
 NewTyCon {
data_con :: DataCon,  The unique constructor
; i
t has no existentials
data_con :: DataCon, 
^
The unique constructor
for the @newtype@. I
t has no existentials
nt_rhs :: Type,  Cached: the argument type of the constructor
 = the representation type of the tycon
 The free tyvars of this type are the tyConTyVars
nt_rhs :: Type,  ^ Cached value: the argument type of the constructor, which
 is just the representation type of the 'TyCon' (remember that
 @newtype@s do not exist at runtime so need a different representation
 type).

 The free 'TyVar's of this type are the 'tyConTyVars' from the corresponding
 'TyCon'
nt_etad_rhs :: ([TyVar], Type),
 ^ Same as the 'nt_rhs', but this time etareduced. Hence the list of 'TyVar's in
 this field may be shorter than the declared arity of the 'TyCon'.
 See Note [Newtype eta]
nt_co :: Maybe TyCon  ^ A 'TyCon' (which is always a 'CoercionTyCon') that can have a 'Coercion'
 extracted from it to create the @newtype@ from the representation 'Type'.

 This field is optional for nonrecursive @newtype@s only.
nt_co :: Maybe TyCon,  A CoercionTyCon used to create the newtype
 from the representation
 Optional for nonrecursive newtypes
 See Note [Newtype coercions]
 Invariant: arity = #tvs in nt_etad_rhs;
 See Note [Newtype eta]
 Watch out! If any newtypes become transparent
 again check Trac #1072.
nt_etad_rhs :: ([TyVar], Type)
 The same again, but this time etareduced
 hence the [TyVar] which may be shorter than the declared
 arity of the TyCon. See Note [Newtype eta]
}
  Extract those 'DataCon's that we are able to learn about. Note that visibility in this sense does not
 correspond to visibility in the context of any particular user program!
visibleDataCons :: AlgTyConRhs > [DataCon]
visibleDataCons AbstractTyCon = []
visibleDataCons OpenTyCon {} = []
visibleDataCons (DataTyCon{ data_cons = cs }) = cs
visibleDataCons (NewTyCon{ data_con = c }) = [c]
 Both type classes as well as family instances imply implicit

^
Both type classes as well as family instances imply implicit
 type constructors. These implicit type constructors refer to their parent
 structure (ie, the class or family from which they derive) using a type of
 the following form. We use `TyConParent' for both algebraic and synonym
 types, but the variant `ClassTyCon' will only be used by algebraic tycons.
 the following form. We use 'TyConParent' for both algebraic and synonym
 types, but the variant 'ClassTyCon' will only be used by algebraic 'TyCon's.
data TyConParent
= NoParentTyCon  An ordinary type constructor has no parent.
=   An ordinary type constructor has no parent.
NoParentTyCon
 ClassTyCon  Type constructors representing a class dictionary.
  Type constructors representing a class dictionary.
 ClassTyCon
Class  INVARIANT: the classTyCon of this Class is the current tycon
 FamilyTyCon  Type constructors representing an instance of a type
TyCon  The type family
[Type]  Instance types; free variables are the tyConTyVars
 of the current TyCon (not the family one)
 INVARIANT: the number of types matches the arity
 of the family tycon
TyCon  A CoercionTyCon identifying the representation
 type with the type instance family.
 c.f. Note [Newtype coercions]
  Type constructors representing an instance of a type family. Parameters:

 1) The type family in question

 2) Instance types; free variables are the 'tyConTyVars'
 of the current 'TyCon' (not the family one). INVARIANT:
 the number of types matches the arity of the family 'TyCon'

 3) A 'CoercionTyCon' identifying the representation
 type with the type instance family
 FamilyTyCon
TyCon
[Type]
TyCon  c.f. Note [Newtype coercions]

 E.g. data intance T [a] = ...
...
...
@@ 293,23 +359,29 @@ data TyConParent
 axiom co a :: T [a] ~ :R7T a
 with :R7T's algTcParent = FamilyTyCon T [a] co
okParent :: Name > TyConParent > Bool  Checks invariants
  Checks the invariants of a 'TyConParent' given the appropriate type class name, if any
okParent :: Name > TyConParent > Bool
okParent _ NoParentTyCon = True
okParent tc_name (ClassTyCon cls) = tyConName (classTyCon cls) == tc_name
okParent _ (FamilyTyCon fam_tc tys _co_tc) = tyConArity fam_tc == length tys

  Information pertaining to the expansion of a type synonym (@type@)
data SynTyConRhs
= OpenSynTyCon Kind  Type family: *result* kind given
(Maybe [Int])  for associated families: for each tyvars in
 the AT decl, gives the position of that
 tyvar in the class argument list (starting
= OpenSynTyCon Kind
(Maybe [Int])  ^ A Type family synonym. The /result/ 'Kind' is
 given for associated families, and in this case the
 list of @Int@s is not empty, and for each 'TyVar' in
 the associated type declaration, it gives the position
 of that 'TyVar' in the class argument list (starting
 from 0).
 NB: Length is less than tyConArity
 if higher kind signature.

 NB: The length of this list will be less than 'tyConArity' iff
 the family has a higher kind signature.
 SynonymTyCon Type 
M
ention
ing
head type var
s. Acts as a template for
 the expansion when the
tyc
on is applied to some
 SynonymTyCon Type 
^ The synonym m
ention
s
head type var
iables. It acts as a

template for
the expansion when the
'TyC
on
'
is applied to some
 types.
\end{code}
...
...
@@ 426,10 +498,6 @@ Then
%* *
%************************************************************************
A PrimRep is an abstraction of a type. It contains information that
the code generator needs in order to pass arguments, return results,
and store values of this type.
A PrimRep is somewhat similar to a CgRep (see codeGen/SMRep) and a
MachRep (see cmm/MachOp), although each of these types has a distinct
and clearly defined purpose:
...
...
@@ 445,14 +513,17 @@ and clearly defined purpose:
reps that don't have corresponding Haskell types).
\begin{code}
  A 'PrimRep' is an abstraction of a type. It contains information that
 the code generator needs in order to pass arguments, return results,
 and store values of this type.
data PrimRep
= VoidRep
 PtrRep
 IntRep 
s
igned, wordsized
 WordRep 
u
nsi
n
ged, wordsized
 Int64Rep 
s
igned, 64 bit
(
32bit words only)
 Word64Rep 
u
nsigned, 64 bit
(
32bit words only)
 AddrRep 
a
pointer, but not to a Haskell value
 IntRep 
^ S
igned, wordsized
value
 WordRep 
^ U
nsig
n
ed, wordsized
value
 Int64Rep 
^ S
igned, 64 bit
value (with
32bit words only)
 Word64Rep 
^ U
nsigned, 64 bit
value (with
32bit words only)
 AddrRep 
^ A
pointer, but
/
not
/
to a Haskell value
(use 'PtrRep')
 FloatRep
 DoubleRep
deriving( Eq, Show )
...
...
@@ 460,7 +531,7 @@ data PrimRep
instance Outputable PrimRep where
ppr r = text (show r)

S
ize of a PrimRep, in words

 Find the s
ize of a
'
PrimRep
'
, in words
primRepSizeW :: PrimRep > Int
primRepSizeW IntRep = 1
primRepSizeW WordRep = 1
...
...
@@ 486,6 +557,9 @@ module mutualrecursion. And they aren't called from many places.
So we compromise, and move their Kind calculation to the call site.
\begin{code}
  Given the name of the function type constructor and it's kind, create the
 corresponding 'TyCon'. It is reccomended to use 'TypeRep.funTyCon' if you want
 this functionality
mkFunTyCon :: Name > Kind > TyCon
mkFunTyCon name kind
= FunTyCon {
...
...
@@ 495,19 +569,18 @@ mkFunTyCon name kind
tyConArity = 2
}
 This is the making of a TyCon. Just the same as the old mkAlgTyCon,
 but now you also have to pass in the generic information about the type
 constructor  you can get hold of it easily (see Generics module)
  This is the making of an algebraic 'TyCon'. Notably, you have to pass in the generic (in the XGenerics sense)
 information about the type constructor  you can get hold of it easily (see Generics module)
mkAlgTyCon :: Name
> Kind
> [TyVar]
> [PredType]
> AlgTyConRhs
> [Id]
> Kind
 ^ Kind of the resulting 'TyCon'
> [TyVar]
 ^ 'TyVar's scoped over: see 'tyConTyVars'. Arity is inferred from the length of this list
> [PredType]
 ^ Stupid theta: see 'algTcStupidTheta'
> AlgTyConRhs
 ^ Information about dat aconstructors
> [Id]
 ^ Selector 'Id's
> TyConParent
> RecFlag
> Bool
> Bool
> RecFlag
 ^ Is the 'TyCon' recursive?
> Bool
 ^ Does it have generic functions? See 'hasGenerics'
> Bool
 ^ Was the 'TyCon' declared with GADT syntax?
> TyCon
mkAlgTyCon name kind tyvars stupid rhs sel_ids parent is_rec gen_info gadt_syn
= AlgTyCon {
...
...
@@ 525,11 +598,19 @@ mkAlgTyCon name kind tyvars stupid rhs sel_ids parent is_rec gen_info gadt_syn
hasGenerics = gen_info
}
  Simpler specialization of 'mkAlgTyCon' for classes
mkClassTyCon :: Name > Kind > [TyVar] > AlgTyConRhs > Class > RecFlag > TyCon
mkClassTyCon name kind tyvars rhs clas is_rec =
mkAlgTyCon name kind tyvars [] rhs [] (ClassTyCon clas) is_rec False False
mkTupleTyCon :: Name > Kind > Arity > [TyVar] > DataCon > Boxity > Bool > TyCon
mkTupleTyCon :: Name
> Kind  ^ Kind of the resulting 'TyCon'
> Arity  ^ Arity of the tuple
> [TyVar]  ^ 'TyVar's scoped over: see 'tyConTyVars'
> DataCon
> Boxity  ^ Whether the tuple is boxed or unboxed
> Bool  ^ Does it have generic functions? See 'hasGenerics'
> TyCon
mkTupleTyCon name kind arity tyvars con boxed gen_info
= TupleTyCon {
tyConUnique = nameUnique name,
...
...
@@ 542,11 +623,15 @@ mkTupleTyCon name kind arity tyvars con boxed gen_info
hasGenerics = gen_info
}
 Foreignimported (.NET) type constructors are represented
 as primitive, but *lifted*, TyCons for now. They are lifted
 because the Haskell type T representing the (foreign) .NET
 type T is actually implemented (in ILX) as a thunk<T>
mkForeignTyCon :: Name > Maybe FastString > Kind > Arity > TyCon
 ^ Foreignimported (.NET) type constructors are represented
 as primitive, but /lifted/, 'TyCons' for now. They are lifted
 because the Haskell type @T@ representing the (foreign) .NET
 type @T@ is actually implemented (in ILX) as a @thunk<T>@
mkForeignTyCon :: Name
> Maybe FastString  ^ Name of the foreign imported thing, maybe
> Kind
> Arity
> TyCon
mkForeignTyCon name ext_name kind arity
= PrimTyCon {
tyConName = name,
...
...
@@ 559,16 +644,17 @@ mkForeignTyCon name ext_name kind arity
}

most Prim tycons are lifted

 Create an unlifted primitive 'TyCon', such as @Int#@
mkPrimTyCon :: Name > Kind > Arity > PrimRep > TyCon
mkPrimTyCon name kind arity rep
= mkPrimTyCon' name kind arity rep True
  Create the special void 'TyCon' which is unlifted and has 'VoidRep'
mkVoidPrimTyCon :: Name > Kind > Arity > TyCon
mkVoidPrimTyCon name kind arity
= mkPrimTyCon' name kind arity VoidRep True

but RealWorld is lifted

 Create a lifted primitive 'TyCon' such as @RealWorld@
mkLiftedPrimTyCon :: Name > Kind > Arity > PrimRep > TyCon
mkLiftedPrimTyCon name kind arity rep
= mkPrimTyCon' name kind arity rep False
...
...
@@ 585,6 +671,7 @@ mkPrimTyCon' name kind arity rep is_unlifted
tyConExtName = Nothing
}
  Create a type synonym 'TyCon'
mkSynTyCon :: Name > Kind > [TyVar] > SynTyConRhs > TyConParent > TyCon
mkSynTyCon name kind tyvars rhs parent
= SynTyCon {
...
...
@@ 597,6 +684,7 @@ mkSynTyCon name kind tyvars rhs parent
synTcParent = parent
}
  Create a coercion 'TyCon'
mkCoercionTyCon :: Name > Arity > ([Type] > (Type,Type)) > TyCon
mkCoercionTyCon name arity kindRule
= CoercionTyCon {
...
...
@@ 606,8 +694,8 @@ mkCoercionTyCon name arity kindRule
coKindFun = kindRule
}

S
uper
kind
s always have arity zero
mkSuperKindTyCon :: Name > TyCon

 Create a s
uper

kind
'TyCon'
mkSuperKindTyCon :: Name > TyCon
 Super kinds always have arity zero
mkSuperKindTyCon name
= SuperKindTyCon {
tyConName = name,
...
...
@@ 620,42 +708,45 @@ isFunTyCon :: TyCon > Bool
isFunTyCon (FunTyCon {}) = True
isFunTyCon _ = False
  Test if the 'TyCon' is algebraic but abstract (invisible data constructors)
isAbstractTyCon :: TyCon >