Safe Haskell  SafeInfered 

 data TyCon
 type FieldLabel = Name
 data AlgTyConRhs
 visibleDataCons :: AlgTyConRhs > [DataCon]
 data TyConParent
 = NoParentTyCon
  ClassTyCon Class
  IPTyCon (IPName Name)
  AssocFamilyTyCon Class
  FamInstTyCon TyCon [Type] CoAxiom
 isNoParent :: TyConParent > Bool
 data SynTyConRhs
 data CoAxiom = CoAxiom {
 co_ax_unique :: Unique
 co_ax_name :: Name
 co_ax_tvs :: [TyVar]
 co_ax_lhs :: Type
 co_ax_rhs :: Type
 coAxiomName :: CoAxiom > Name
 coAxiomArity :: CoAxiom > Arity
 mkAlgTyCon :: Name > Kind > [TyVar] > [PredType] > AlgTyConRhs > TyConParent > RecFlag > Bool > TyCon
 mkClassTyCon :: Name > Kind > [TyVar] > AlgTyConRhs > Class > RecFlag > TyCon
 mkIParamTyCon :: Name > Kind > TyVar > AlgTyConRhs > RecFlag > TyCon
 mkFunTyCon :: Name > Kind > TyCon
 mkPrimTyCon :: Name > Kind > Arity > PrimRep > TyCon
 mkKindTyCon :: Name > Kind > TyCon
 mkLiftedPrimTyCon :: Name > Kind > Arity > PrimRep > TyCon
 mkTupleTyCon :: Name > Kind > Arity > [TyVar] > DataCon > TupleSort > TyCon
 mkSynTyCon :: Name > Kind > [TyVar] > SynTyConRhs > TyConParent > TyCon
 mkSuperKindTyCon :: Name > TyCon
 mkForeignTyCon :: Name > Maybe FastString > Kind > Arity > TyCon
 mkPromotedDataTyCon :: DataCon > Name > Unique > Kind > TyCon
 mkPromotedTypeTyCon :: TyCon > TyCon
 isAlgTyCon :: TyCon > Bool
 isClassTyCon :: TyCon > Bool
 isFamInstTyCon :: TyCon > Bool
 isFunTyCon :: TyCon > Bool
 isPrimTyCon :: TyCon > Bool
 isTupleTyCon :: TyCon > Bool
 isUnboxedTupleTyCon :: TyCon > Bool
 isBoxedTupleTyCon :: TyCon > Bool
 isSynTyCon :: TyCon > Bool
 isClosedSynTyCon :: TyCon > Bool
 isSuperKindTyCon :: TyCon > Bool
 isDecomposableTyCon :: TyCon > Bool
 isForeignTyCon :: TyCon > Bool
 tyConHasKind :: TyCon > Bool
 isPromotedDataTyCon :: TyCon > Bool
 isPromotedTypeTyCon :: TyCon > Bool
 isInjectiveTyCon :: TyCon > Bool
 isDataTyCon :: TyCon > Bool
 isProductTyCon :: TyCon > Bool
 isEnumerationTyCon :: TyCon > Bool
 isNewTyCon :: TyCon > Bool
 isAbstractTyCon :: TyCon > Bool
 isFamilyTyCon :: TyCon > Bool
 isSynFamilyTyCon :: TyCon > Bool
 isDataFamilyTyCon :: TyCon > Bool
 isUnLiftedTyCon :: TyCon > Bool
 isGadtSyntaxTyCon :: TyCon > Bool
 isDistinctTyCon :: TyCon > Bool
 isDistinctAlgRhs :: AlgTyConRhs > Bool
 isTyConAssoc :: TyCon > Bool
 tyConAssoc_maybe :: TyCon > Maybe Class
 isRecursiveTyCon :: TyCon > Bool
 isImplicitTyCon :: TyCon > Bool
 tyConName :: TyCon > Name
 tyConKind :: TyCon > Kind
 tyConUnique :: TyCon > Unique
 tyConTyVars :: TyCon > [TyVar]
 tyConDataCons :: TyCon > [DataCon]
 tyConDataCons_maybe :: TyCon > Maybe [DataCon]
 tyConSingleDataCon_maybe :: TyCon > Maybe DataCon
 tyConFamilySize :: TyCon > Int
 tyConStupidTheta :: TyCon > [PredType]
 tyConArity :: TyCon > Arity
 tyConParent :: TyCon > TyConParent
 tyConTuple_maybe :: TyCon > Maybe TupleSort
 tyConClass_maybe :: TyCon > Maybe Class
 tyConIP_maybe :: TyCon > Maybe (IPName Name)
 tyConFamInst_maybe :: TyCon > Maybe (TyCon, [Type])
 tyConFamilyCoercion_maybe :: TyCon > Maybe CoAxiom
 tyConFamInstSig_maybe :: TyCon > Maybe (TyCon, [Type], CoAxiom)
 synTyConDefn :: TyCon > ([TyVar], Type)
 synTyConRhs :: TyCon > SynTyConRhs
 synTyConType :: TyCon > Type
 tyConExtName :: TyCon > Maybe FastString
 algTyConRhs :: TyCon > AlgTyConRhs
 newTyConRhs :: TyCon > ([TyVar], Type)
 newTyConEtadRhs :: TyCon > ([TyVar], Type)
 unwrapNewTyCon_maybe :: TyCon > Maybe ([TyVar], Type, CoAxiom)
 tupleTyConBoxity :: TyCon > Boxity
 tupleTyConSort :: TyCon > TupleSort
 tupleTyConArity :: TyCon > Arity
 tcExpandTyCon_maybe, coreExpandTyCon_maybe :: TyCon > [tyco] > Maybe ([(TyVar, tyco)], Type, [tyco])
 makeTyConAbstract :: TyCon > TyCon
 newTyConCo :: TyCon > CoAxiom
 newTyConCo_maybe :: TyCon > Maybe CoAxiom
 data PrimRep
 tyConPrimRep :: TyCon > PrimRep
 primRepSizeW :: PrimRep > Int
Main TyCon data types
TyCons represent 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 *
This data type also encodes a number of primitive, built in type constructors such as those for function and tuple types.
type FieldLabel = NameSource
Names of the fields in an algebraic record type
data AlgTyConRhs Source
Represents righthandsides of TyCon
s for algebraic types
AbstractTyCon Bool  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. 
DataFamilyTyCon  Represents 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 declaration: data T a :: * Or an associated data type declaration, within a class declaration: class C a b where data T b :: * 
DataTyCon  Information about those 
 
NewTyCon  Information about those 

visibleDataCons :: AlgTyConRhs > [DataCon]Source
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 TyCon
s.
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!
data TyConParent Source
NoParentTyCon  An ordinary type constructor has no parent. 
ClassTyCon Class  Type constructors representing a class dictionary. See Note [ATyCon for classes] in TypeRep 
IPTyCon (IPName Name)  Associated type of a implicit parameter. 
AssocFamilyTyCon Class  An *associated* type of a class. 
FamInstTyCon TyCon [Type] CoAxiom  Type constructors representing an instance of a type family. Parameters: 1) The type family in question 2) Instance types; free variables are the 3) A 
isNoParent :: TyConParent > BoolSource
data SynTyConRhs Source
Information pertaining to the expansion of a type synonym (type
)
SynonymTyCon Type  An ordinary type synonyn. 
SynFamilyTyCon  A type synonym family e.g. 
Coercion axiom constructors
A CoAxiom
is a "coercion constructor", i.e. a named equality axiom.
coAxiomName :: CoAxiom > NameSource
coAxiomArity :: CoAxiom > AritySource
Constructing TyCons
:: Name  
> Kind  Kind of the resulting 
> [TyVar] 

> [PredType]  Stupid theta: see 
> AlgTyConRhs  Information about dat aconstructors 
> TyConParent  
> RecFlag  Is the 
> Bool  Was the 
> TyCon 
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)
mkClassTyCon :: Name > Kind > [TyVar] > AlgTyConRhs > Class > RecFlag > TyConSource
Simpler specialization of mkAlgTyCon
for classes
mkIParamTyCon :: Name > Kind > TyVar > AlgTyConRhs > RecFlag > TyConSource
Simpler specialization of mkAlgTyCon
for implicit paramaters
mkFunTyCon :: Name > Kind > TyConSource
mkPrimTyCon :: Name > Kind > Arity > PrimRep > TyConSource
Create an unlifted primitive TyCon
, such as Int#
mkKindTyCon :: Name > Kind > TyConSource
Kind constructors
mkLiftedPrimTyCon :: Name > Kind > Arity > PrimRep > TyConSource
Create a lifted primitive TyCon
such as RealWorld
:: Name  
> Kind  Kind of the resulting 
> Arity  Arity of the tuple 
> [TyVar] 

> DataCon  
> TupleSort  Whether the tuple is boxed or unboxed 
> 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 thunkT
mkSynTyCon :: Name > Kind > [TyVar] > SynTyConRhs > TyConParent > TyConSource
Create a type synonym TyCon
mkSuperKindTyCon :: Name > TyConSource
Create a superkind TyCon
mkPromotedDataTyCon :: DataCon > Name > Unique > Kind > TyConSource
Create a promoted data constructor TyCon
mkPromotedTypeTyCon :: TyCon > TyConSource
Create a promoted type constructor TyCon
Predicates on TyCons
isAlgTyCon :: TyCon > BoolSource
Returns True
if the supplied TyCon
resulted from either a
data
or newtype
declaration
isClassTyCon :: TyCon > BoolSource
Is this TyCon
that for a class instance?
isFamInstTyCon :: TyCon > BoolSource
Is this TyCon
that for a family instance, be that for a synonym or an
algebraic family instance?
isFunTyCon :: TyCon > BoolSource
isPrimTyCon :: TyCon > BoolSource
Does this TyCon
represent something that cannot be defined in Haskell?
isTupleTyCon :: TyCon > BoolSource
Does this TyCon
represent a tuple?
NB: when compiling Data.Tuple
, the tycons won't reply True
to
isTupleTyCon
, becuase they are built as AlgTyCons
. However they
get spat into the interface file as tuple tycons, so I don't think
it matters.
isUnboxedTupleTyCon :: TyCon > BoolSource
Is this the TyCon
for an unboxed tuple?
isBoxedTupleTyCon :: TyCon > BoolSource
Is this the TyCon
for a boxed tuple?
isSynTyCon :: TyCon > BoolSource
Is this a TyCon
representing a type synonym (type
)?
isClosedSynTyCon :: TyCon > BoolSource
Is this a synonym TyCon
that can have no further instances appear?
isSuperKindTyCon :: TyCon > BoolSource
Is this a superkind TyCon
?
isForeignTyCon :: TyCon > BoolSource
Is this the TyCon
of a foreignimported type constructor?
tyConHasKind :: TyCon > BoolSource
isPromotedDataTyCon :: TyCon > BoolSource
Is this a PromotedDataTyCon?
isPromotedTypeTyCon :: TyCon > BoolSource
Is this a PromotedTypeTyCon?
isInjectiveTyCon :: TyCon > BoolSource
Injective TyCon
s can be decomposed, so that
T ty1 ~ T ty2 => ty1 ~ ty2
isDataTyCon :: TyCon > BoolSource
Returns True
for data types that are definitely represented by
heapallocated constructors. These are scrutinised by Corelevel
case
expressions, and they get info tables allocated for them.
Generally, the function will be true for all data
types and false
for newtype
s, unboxed tuples and type family TyCon
s. But it is
not guaranteed to return True
in all cases that it could.
NB: for a data type family, only the instance TyCon
s
get an info table. The family declaration TyCon
does not
isProductTyCon :: TyCon > BoolSource
isEnumerationTyCon :: TyCon > BoolSource
Is this an algebraic TyCon
which is just an enumeration of values?
isNewTyCon :: TyCon > BoolSource
Is this TyCon
that for a newtype
isAbstractTyCon :: TyCon > BoolSource
Test if the TyCon
is algebraic but abstract (invisible data constructors)
isFamilyTyCon :: TyCon > BoolSource
Is this a TyCon
, synonym or otherwise, that may have further instances appear?
isSynFamilyTyCon :: TyCon > BoolSource
Is this a synonym TyCon
that can have may have further instances appear?
isDataFamilyTyCon :: TyCon > BoolSource
Is this a synonym TyCon
that can have may have further instances appear?
isUnLiftedTyCon :: TyCon > BoolSource
isGadtSyntaxTyCon :: TyCon > BoolSource
Is this an algebraic TyCon
declared with the GADT syntax?
isDistinctTyCon :: TyCon > BoolSource
isDistinctTyCon
is true of TyCon
s that are equal only to
themselves, even via coercions (except for unsafeCoerce).
This excludes newtypes, type functions, type synonyms.
It relates directly to the FC consistency story:
If the axioms are consistent,
and co : S tys ~ T tys, and S,T are distinct TyCons,
then S=T.
Cf Note [Pruning dead case alternatives] in Unify
isTyConAssoc :: TyCon > BoolSource
isRecursiveTyCon :: TyCon > BoolSource
Is this a recursive TyCon
?
isImplicitTyCon :: TyCon > BoolSource
Identifies implicit tycons that, in particular, do not go into interface files (because they are implicitly reconstructed when the interface is read).
Note that:
 Associated families are implicit, as they are reconstructed from the class declaration in which they reside, and
 Family instances are not implicit as they represent the instance body
(similar to a
dfun
does that for a class instance).
Extracting information out of TyCons
tyConUnique :: TyCon > UniqueSource
Same Unique as the type constructor
Same Unique as the data constructor
tyConTyVars :: TyCon > [TyVar]Source
The kind and type variables used in the type constructor. Invariant: length tyvars = arity Precisely, this list scopes over:
 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.
tyConDataCons :: TyCon > [DataCon]Source
As tyConDataCons_maybe
, but returns the empty list of constructors if no constructors
could be found
tyConDataCons_maybe :: TyCon > Maybe [DataCon]Source
tyConSingleDataCon_maybe :: TyCon > Maybe DataConSource
If the given TyCon
has a single data constructor, i.e. it is a data
type with one
alternative, a tuple type or a newtype
then that constructor is returned. If the TyCon
has more than one constructor, or represents a primitive or function type constructor then
Nothing
is returned. In any other case, the function panics
tyConFamilySize :: TyCon > IntSource
tyConStupidTheta :: TyCon > [PredType]Source
Find the "stupid theta" of the TyCon
. 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 ...
tyConArity :: TyCon > AritySource
n if ty_con :: * > ... > * n times
tyConClass_maybe :: TyCon > Maybe ClassSource
If this TyCon
is that for a class instance, return the class it is for.
Otherwise returns Nothing
tyConIP_maybe :: TyCon > Maybe (IPName Name)Source
If this TyCon
is that for implicit parameter, return the IP it is for.
Otherwise returns Nothing
tyConFamInst_maybe :: TyCon > Maybe (TyCon, [Type])Source
If this TyCon
is that of a family instance, return the family in question
and the instance types. Otherwise, return Nothing
synTyConDefn :: TyCon > ([TyVar], Type)Source
synTyConRhs :: TyCon > SynTyConRhsSource
Extract the information pertaining to the right hand side of a type synonym (type
) declaration. Panics
if the given TyCon
is not a type synonym
synTyConType :: TyCon > TypeSource
tyConExtName :: TyCon > Maybe FastStringSource
Just e
for foreignimported types,
holds the name of the imported thing
algTyConRhs :: TyCon > AlgTyConRhsSource
Extract an AlgTyConRhs
with information about data constructors from an algebraic or tuple
TyCon
. Panics for any other sort of TyCon
newTyConRhs :: TyCon > ([TyVar], Type)Source
newTyConEtadRhs :: TyCon > ([TyVar], Type)Source
tupleTyConBoxity :: TyCon > BoxitySource
Extract the boxity of the given TyCon
, if it is a TupleTyCon
.
Panics otherwise
tupleTyConArity :: TyCon > AritySource
Extract the arity of the given TyCon
, if it is a TupleTyCon
.
Panics otherwise
Manipulating TyCons
tcExpandTyCon_maybe,coreExpandTyCon_maybeSource
:: TyCon  
> [tyco]  Arguments to 
> Maybe ([(TyVar, tyco)], Type, [tyco])  Returns a 
Used to create the view Core has on TyCon
s. We expand
not only closed synonyms like tcExpandTyCon_maybe
,
but also nonrecursive newtype
s
Used to create the view the typechecker has on TyCon
s.
We expand (closed) synonyms only, cf. coreExpandTyCon_maybe
newTyConCo :: TyCon > CoAxiomSource
Primitive representations of Types
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.
tyConPrimRep :: TyCon > PrimRepSource
Find the primitive representation of a TyCon
primRepSizeW :: PrimRep > IntSource
Find the size of a PrimRep
, in words