ghc-7.10.3: The GHC API

Safe Haskell | None
Language | Haskell2010

TyCon

Contents

- Main TyCon data types
  - Constructing TyCons
  - Predicates on TyCons
  - Extracting information out of TyCons
  - Manipulating TyCons
- Primitive representations of Types
- Recursion breaking

Synopsis

- data TyCon
- type FieldLabel = Name
- data AlgTyConRhs
  - = AbstractTyCon Bool
  - | DataFamilyTyCon
  - | DataTyCon {
    - data_cons :: [DataCon]
    - is_enum :: Bool
    }
  - | NewTyCon {
    - data_con :: DataCon
    - nt_rhs :: Type
    - nt_etad_rhs :: ([TyVar], Type)
    - nt_co :: CoAxiom Unbranched
    }
- visibleDataCons :: AlgTyConRhs -> [DataCon]
- data TyConParent
  - = NoParentTyCon
  - | ClassTyCon Class
  - | AssocFamilyTyCon Class
  - | FamInstTyCon (CoAxiom Unbranched) TyCon [Type]
- isNoParent :: TyConParent -> Bool
- data FamTyConFlav
  - = OpenSynFamilyTyCon
  - | ClosedSynFamilyTyCon (CoAxiom Branched)
  - | AbstractClosedSynFamilyTyCon
  - | BuiltInSynFamTyCon BuiltInSynFamily
- data Role
  - = Nominal
  - | Representational
  - | Phantom
- mkAlgTyCon :: Name -> Kind -> [TyVar] -> [Role] -> Maybe CType -> [PredType] -> AlgTyConRhs -> TyConParent -> RecFlag -> Bool -> Maybe TyCon -> TyCon
- mkClassTyCon :: Name -> Kind -> [TyVar] -> [Role] -> AlgTyConRhs -> Class -> RecFlag -> TyCon
- mkFunTyCon :: Name -> Kind -> TyCon
- mkPrimTyCon :: Name -> Kind -> [Role] -> PrimRep -> TyCon
- mkKindTyCon :: Name -> Kind -> TyCon
- mkLiftedPrimTyCon :: Name -> Kind -> [Role] -> PrimRep -> TyCon
- mkTupleTyCon :: Name -> Kind -> Arity -> [TyVar] -> DataCon -> TupleSort -> Maybe TyCon -> TyCon
- mkSynonymTyCon :: Name -> Kind -> [TyVar] -> [Role] -> Type -> TyCon
- mkFamilyTyCon :: Name -> Kind -> [TyVar] -> FamTyConFlav -> TyConParent -> TyCon
- mkPromotedDataCon :: DataCon -> Name -> Unique -> Kind -> [Role] -> TyCon
- mkPromotedTyCon :: TyCon -> Kind -> 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
- isTypeSynonymTyCon :: TyCon -> Bool
- isDecomposableTyCon :: TyCon -> Bool
- isPromotedDataCon :: TyCon -> Bool
- isPromotedTyCon :: TyCon -> Bool
- isPromotedDataCon_maybe :: TyCon -> Maybe DataCon
- isPromotedTyCon_maybe :: TyCon -> Maybe TyCon
- promotableTyCon_maybe :: TyCon -> Maybe TyCon
- promoteTyCon :: TyCon -> TyCon
- isDataTyCon :: TyCon -> Bool
- isProductTyCon :: TyCon -> Bool
- isDataProductTyCon_maybe :: TyCon -> Maybe DataCon
- isEnumerationTyCon :: TyCon -> Bool
- isNewTyCon :: TyCon -> Bool
- isAbstractTyCon :: TyCon -> Bool
- isFamilyTyCon :: TyCon -> Bool
- isOpenFamilyTyCon :: TyCon -> Bool
- isTypeFamilyTyCon :: TyCon -> Bool
- isDataFamilyTyCon :: TyCon -> Bool
- isOpenTypeFamilyTyCon :: TyCon -> Bool
- isClosedSynFamilyTyCon_maybe :: TyCon -> Maybe (CoAxiom Branched)
- isBuiltInSynFamTyCon_maybe :: TyCon -> Maybe BuiltInSynFamily
- isUnLiftedTyCon :: TyCon -> Bool
- isGadtSyntaxTyCon :: TyCon -> Bool
- isDistinctTyCon :: TyCon -> Bool
- isDistinctAlgRhs :: AlgTyConRhs -> Bool
- isInjectiveTyCon :: TyCon -> Role -> Bool
- isGenerativeTyCon :: TyCon -> Role -> Bool
- isGenInjAlgRhs :: 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]
- tyConCType :: TyCon -> Maybe CType
- tyConCType_maybe :: TyCon -> Maybe CType
- tyConDataCons :: TyCon -> [DataCon]
- tyConDataCons_maybe :: TyCon -> Maybe [DataCon]
- tyConSingleDataCon_maybe :: TyCon -> Maybe DataCon
- tyConSingleAlgDataCon_maybe :: TyCon -> Maybe DataCon
- tyConFamilySize :: TyCon -> Int
- tyConStupidTheta :: TyCon -> [PredType]
- tyConArity :: TyCon -> Arity
- tyConRoles :: TyCon -> [Role]
- tyConParent :: TyCon -> TyConParent
- tyConTuple_maybe :: TyCon -> Maybe TupleSort
- tyConClass_maybe :: TyCon -> Maybe Class
- tyConFamInst_maybe :: TyCon -> Maybe (TyCon, [Type])
- tyConFamInstSig_maybe :: TyCon -> Maybe (TyCon, [Type], CoAxiom Unbranched)
- tyConFamilyCoercion_maybe :: TyCon -> Maybe (CoAxiom Unbranched)
- synTyConDefn_maybe :: TyCon -> Maybe ([TyVar], Type)
- synTyConRhs_maybe :: TyCon -> Maybe Type
- famTyConFlav_maybe :: TyCon -> Maybe FamTyConFlav
- algTyConRhs :: TyCon -> AlgTyConRhs
- newTyConRhs :: TyCon -> ([TyVar], Type)
- newTyConEtadArity :: TyCon -> Int
- newTyConEtadRhs :: TyCon -> ([TyVar], Type)
- unwrapNewTyCon_maybe :: TyCon -> Maybe ([TyVar], Type, CoAxiom Unbranched)
- unwrapNewTyConEtad_maybe :: TyCon -> Maybe ([TyVar], Type, CoAxiom Unbranched)
- tupleTyConBoxity :: TyCon -> Boxity
- tupleTyConSort :: TyCon -> TupleSort
- tupleTyConArity :: TyCon -> Arity
- tcExpandTyCon_maybe :: TyCon -> [tyco] -> Maybe ([(TyVar, tyco)], Type, [tyco])
- coreExpandTyCon_maybe :: TyCon -> [tyco] -> Maybe ([(TyVar, tyco)], Type, [tyco])
- makeTyConAbstract :: TyCon -> TyCon
- newTyConCo :: TyCon -> CoAxiom Unbranched
- newTyConCo_maybe :: TyCon -> Maybe (CoAxiom Unbranched)
- pprPromotionQuote :: TyCon -> SDoc
- data PrimRep
  - = VoidRep
  - | PtrRep
  - | IntRep
  - | WordRep
  - | Int64Rep
  - | Word64Rep
  - | AddrRep
  - | FloatRep
  - | DoubleRep
  - | VecRep Int PrimElemRep
- data PrimElemRep
  - = Int8ElemRep
  - | Int16ElemRep
  - | Int32ElemRep
  - | Int64ElemRep
  - | Word8ElemRep
  - | Word16ElemRep
  - | Word32ElemRep
  - | Word64ElemRep
  - | FloatElemRep
  - | DoubleElemRep
- tyConPrimRep :: TyCon -> PrimRep
- isVoidRep :: PrimRep -> Bool
- isGcPtrRep :: PrimRep -> Bool
- primRepSizeW :: DynFlags -> PrimRep -> Int
- primElemRepSizeB :: PrimElemRep -> Int
- data RecTcChecker
- initRecTc :: RecTcChecker
- checkRecTc :: RecTcChecker -> TyCon -> Maybe RecTcChecker

# Main TyCon data types

data TyCon

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.

Instances

Eq TyCon |
Data TyCon |
Ord TyCon |
Outputable TyCon |
Uniquable TyCon |
NamedThing TyCon |

type FieldLabel = Name

Names of the fields in an algebraic record type

data AlgTyConRhs

Represents right-hand-sides of `TyCon`s for algebraic types

Constructors

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 `TyCon`s derived from a `data` declaration. This includes data types with no constructors at all.

Fields

data_cons :: [DataCon]

  The data type constructors; can be empty if the user declares the type to have no constructors

  INVARIANT: Kept in order of increasing `DataCon` tag (see the tag assignment in DataCon.mkDataCon)

is_enum :: Bool

  Cached value: is this an enumeration type? See Note [Enumeration types]

NewTyCon | Information about those `TyCon`s derived from a `newtype` declaration

Fields

data_con :: DataCon

  The unique constructor for the `newtype`. It has no existentials

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 eta-reduced. Hence the list of `TyVar`s in this field may be shorter than the declared arity of the `TyCon`.

nt_co :: CoAxiom Unbranched

visibleDataCons :: AlgTyConRhs -> [DataCon]

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

Constructors

NoParentTyCon | An ordinary type constructor has no parent.
ClassTyCon Class | Type constructors representing a class dictionary. See Note [ATyCon for classes] in TypeRep
AssocFamilyTyCon Class | An *associated* type of a class.

FamInstTyCon (CoAxiom Unbranched) TyCon [Type]

Type constructors representing an instance of a *data* 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 `CoTyCon` identifying the representation type with the type instance family

Instances

Outputable TyConParent |

isNoParent :: TyConParent -> Bool

data FamTyConFlav

Information pertaining to the expansion of a type synonym (`type`)

Constructors

OpenSynFamilyTyCon | An open type synonym family e.g. `type family F x y :: * -> *`
ClosedSynFamilyTyCon (CoAxiom Branched) | A closed type synonym family e.g. `type family F x where { F Int = Bool }`
AbstractClosedSynFamilyTyCon | A closed type synonym family declared in an hs-boot file with type family F a where ..
BuiltInSynFamTyCon BuiltInSynFamily | Built-in type family used by the TypeNats solver

data Role

Constructors

Nominal |
Representational |
Phantom |

Instances

Eq Role |
Data Role |
Outputable Role |
Binary Role |

## Constructing TyCons

mkAlgTyCon

Arguments

:: Name |
-> Kind | Kind of the resulting `TyCon`
-> [TyVar] | `TyVar`s scoped over: see `tyConTyVars`. Arity is inferred from the length of this list
-> [Role] | The roles for each TyVar
-> Maybe CType | The C type this type corresponds to when using the CAPI FFI
-> [PredType] | Stupid theta: see `algTcStupidTheta`
-> AlgTyConRhs | Information about dat aconstructors
-> TyConParent |
-> RecFlag | Is the `TyCon` recursive?
-> Bool | Was the `TyCon` declared with GADT syntax?
-> Maybe TyCon | Promoted version
-> 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] -> [Role] -> AlgTyConRhs -> Class -> RecFlag -> TyCon

Simpler specialization of `mkAlgTyCon` for classes

mkFunTyCon :: Name -> Kind -> TyCon

Given the name of the function type constructor and it's kind, create the corresponding `TyCon`. It is reccomended to use `funTyCon` if you want this functionality

mkPrimTyCon :: Name -> Kind -> [Role] -> PrimRep -> TyCon

Create an unlifted primitive `TyCon`, such as `Int#`

mkKindTyCon :: Name -> Kind -> TyCon

Kind constructors

mkLiftedPrimTyCon :: Name -> Kind -> [Role] -> PrimRep -> TyCon

Create a lifted primitive `TyCon` such as `RealWorld`

mkTupleTyCon

Arguments

:: Name |
-> Kind | Kind of the resulting `TyCon`
-> Arity | Arity of the tuple
-> [TyVar] | `TyVar`s scoped over: see `tyConTyVars`
-> DataCon |
-> TupleSort | Whether the tuple is boxed or unboxed
-> Maybe TyCon | Promoted version
-> TyCon |

mkSynonymTyCon :: Name -> Kind -> [TyVar] -> [Role] -> Type -> TyCon

Create a type synonym `TyCon`

mkFamilyTyCon :: Name -> Kind -> [TyVar] -> FamTyConFlav -> TyConParent -> TyCon

Create a type family `TyCon`

mkPromotedDataCon :: DataCon -> Name -> Unique -> Kind -> [Role] -> TyCon

Create a promoted data constructor `TyCon` Somewhat dodgily, we give it the same Name as the data constructor itself; when we pretty-print the TyCon we add a quote; see the Outputable TyCon instance

mkPromotedTyCon :: TyCon -> Kind -> TyCon

Create a promoted type constructor `TyCon` Somewhat dodgily, we give it the same Name as the type constructor itself

## Predicates on TyCons

isAlgTyCon :: TyCon -> Bool

Returns `True` if the supplied `TyCon` resulted from either a `data` or `newtype` declaration

isClassTyCon :: TyCon -> Bool

Is this `TyCon` that for a class instance?

isFamInstTyCon :: TyCon -> Bool

Is this `TyCon` that for a data family instance?

isFunTyCon :: TyCon -> Bool

isPrimTyCon :: TyCon -> Bool

Does this `TyCon` represent something that cannot be defined in Haskell?

isTupleTyCon :: TyCon -> Bool

Does this `TyCon` represent a tuple?

NB: when compiling `Data.Tuple`, the tycons won't reply `True` to `isTupleTyCon`, because 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 -> Bool

Is this the `TyCon` for an unboxed tuple?

isBoxedTupleTyCon :: TyCon -> Bool

Is this the `TyCon` for a boxed tuple?

isTypeSynonymTyCon :: TyCon -> Bool

Is this a `TyCon` representing a regular H98 type synonym (`type`)?

isDecomposableTyCon :: TyCon -> Bool

isPromotedDataCon :: TyCon -> Bool

Is this a PromotedDataCon?

isPromotedTyCon :: TyCon -> Bool

Is this a PromotedTyCon?

isPromotedDataCon_maybe :: TyCon -> Maybe DataCon

Retrieves the promoted DataCon if this is a PromotedDataCon;

isPromotedTyCon_maybe :: TyCon -> Maybe TyCon

Retrieves the promoted TyCon if this is a PromotedTyCon;

promotableTyCon_maybe :: TyCon -> Maybe TyCon

promoteTyCon :: TyCon -> TyCon

isDataTyCon :: TyCon -> Bool

Returns `True` for data types that are definitely represented by heap-allocated constructors. These are scrutinised by Core-level `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 -> Bool

isDataProductTyCon_maybe :: TyCon -> Maybe DataCon

isEnumerationTyCon :: TyCon -> Bool

Is this an algebraic `TyCon` which is just an enumeration of values?

isNewTyCon :: TyCon -> Bool

Is this `TyCon` that for a `newtype`

isAbstractTyCon :: TyCon -> Bool

Test if the `TyCon` is algebraic but abstract (invisible data constructors)

isFamilyTyCon :: TyCon -> Bool

Is this a `TyCon`, synonym or otherwise, that defines a family?

isOpenFamilyTyCon :: TyCon -> Bool

Is this a `TyCon`, synonym or otherwise, that defines a family with instances?

isTypeFamilyTyCon :: TyCon -> Bool

Is this a synonym `TyCon` that can have may have further instances appear?

isDataFamilyTyCon :: TyCon -> Bool

Is this a synonym `TyCon` that can have may have further instances appear?

isOpenTypeFamilyTyCon :: TyCon -> Bool

isClosedSynFamilyTyCon_maybe :: TyCon -> Maybe (CoAxiom Branched)

isBuiltInSynFamTyCon_maybe :: TyCon -> Maybe BuiltInSynFamily

isUnLiftedTyCon :: TyCon -> Bool

Is this `TyCon` unlifted (i.e. cannot contain bottom)? Note that this can only be true for primitive and unboxed-tuple `TyCon`s

isGadtSyntaxTyCon :: TyCon -> Bool

Is this an algebraic `TyCon` declared with the GADT syntax?

isDistinctTyCon :: TyCon -> Bool

`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

isDistinctAlgRhs :: AlgTyConRhs -> Bool

isInjectiveTyCon :: TyCon -> Role -> Bool

`isInjectiveTyCon` is true of `TyCon`s for which this property holds (where X is the role passed in): If (T a1 b1 c1) ~X (T a2 b2 c2), then (a1 ~X1 a2), (b1 ~X2 b2), and (c1 ~X3 c2) (where X1, X2, and X3, are the roles given by tyConRolesX tc X) See also Note [Decomposing equalities] in TcCanonical

isGenerativeTyCon :: TyCon -> Role -> Bool

`isGenerativeTyCon` is true of `TyCon`s for which this property holds (where X is the role passed in): If (T tys ~X t), then (t's head ~X T). See also Note [Decomposing equalities] in TcCanonical

isGenInjAlgRhs :: AlgTyConRhs -> Bool

Is this an `AlgTyConRhs` of a `TyCon` that is generative and injective with respect to representational equality?

isTyConAssoc :: TyCon -> Bool

Are we able to extract informationa `TyVar` to class argument list mappping from a given `TyCon`?

tyConAssoc_maybe :: TyCon -> Maybe Class

isRecursiveTyCon :: TyCon -> Bool

Is this a recursive `TyCon`?

isImplicitTyCon :: TyCon -> Bool

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 re-constructed 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

tyConName :: TyCon -> Name

Name of the constructor

tyConKind :: TyCon -> Kind

Kind of this TyCon (full kind, not just the return kind)

tyConUnique :: TyCon -> Unique

A Unique of this TyCon. Invariant: identical to Unique of Name stored in tyConName field.

tyConTyVars :: TyCon -> [TyVar]

The kind and type variables used in the type constructor. Invariant: length tyvars = arity 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.

tyConCType :: TyCon -> Maybe CType

The C type that should be used for this type when using the FFI and CAPI

tyConCType_maybe :: TyCon -> Maybe CType

tyConDataCons :: TyCon -> [DataCon]

As `tyConDataCons_maybe`, but returns the empty list of constructors if no constructors could be found

tyConDataCons_maybe :: TyCon -> Maybe [DataCon]

Determine the `DataCon`s originating from the given `TyCon`, if the `TyCon` is the sort that can have any constructors (note: this does not include abstract algebraic types)

tyConSingleDataCon_maybe :: TyCon -> Maybe DataCon

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

tyConSingleAlgDataCon_maybe :: TyCon -> Maybe DataCon

tyConFamilySize :: TyCon -> Int

Determine the number of value constructors a `TyCon` has. Panics if the `TyCon` is not algebraic or a tuple

tyConStupidTheta :: TyCon -> [PredType]

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 -> Arity

Number of arguments this TyCon must receive to be considered saturated (including implicit kind variables)

tyConRoles :: TyCon -> [Role]

Get the list of roles for the type parameters of a TyCon

tyConParent :: TyCon -> TyConParent

tyConTuple_maybe :: TyCon -> Maybe TupleSort

tyConClass_maybe :: TyCon -> Maybe Class

If this `TyCon` is that for a class instance, return the class it is for. Otherwise returns `Nothing`

tyConFamInst_maybe :: TyCon -> Maybe (TyCon, [Type])

If this `TyCon` is that of a family instance, return the family in question and the instance types. Otherwise, return `Nothing`

tyConFamInstSig_maybe :: TyCon -> Maybe (TyCon, [Type], CoAxiom Unbranched)

tyConFamilyCoercion_maybe :: TyCon -> Maybe (CoAxiom Unbranched)

If this `TyCon` is that of a family instance, return a `TyCon` which represents a coercion identifying the representation type with the type instance family. Otherwise, return `Nothing`

synTyConDefn_maybe :: TyCon -> Maybe ([TyVar], Type)

Extract the `TyVar`s bound by a vanilla type synonym and the corresponding (unsubstituted) right hand side.

synTyConRhs_maybe :: TyCon -> Maybe Type

Extract the information pertaining to the right hand side of a type synonym (`type`) declaration.

famTyConFlav_maybe :: TyCon -> Maybe FamTyConFlav

Extract the flavour of a type family (with all the extra information that it carries)

algTyConRhs :: TyCon -> AlgTyConRhs

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)

Extract the bound type variables and type expansion of a type synonym `TyCon`. Panics if the `TyCon` is not a synonym

newTyConEtadArity :: TyCon -> Int

The number of type parameters that need to be passed to a newtype to resolve it. May be less than in the definition if it can be eta-contracted.

newTyConEtadRhs :: TyCon -> ([TyVar], Type)

Extract the bound type variables and type expansion of an eta-contracted type synonym `TyCon`. Panics if the `TyCon` is not a synonym

unwrapNewTyCon_maybe :: TyCon -> Maybe ([TyVar], Type, CoAxiom Unbranched)

Take a `TyCon` apart into the `TyVar`s it scopes over, the `Type` it expands into, and (possibly) a coercion from the representation type to the `newtype`. Returns `Nothing` if this is not possible.

unwrapNewTyConEtad_maybe :: TyCon -> Maybe ([TyVar], Type, CoAxiom Unbranched)

tupleTyConBoxity :: TyCon -> Boxity

Extract the boxity of the given `TyCon`, if it is a `TupleTyCon`. Panics otherwise

tupleTyConSort :: TyCon -> TupleSort

Extract the `TupleSort` of the given `TyCon`, if it is a `TupleTyCon`. Panics otherwise

tupleTyConArity :: TyCon -> Arity

Extract the arity of the given `TyCon`, if it is a `TupleTyCon`. Panics otherwise

## Manipulating TyCons

tcExpandTyCon_maybe

Arguments

:: TyCon |
-> [tyco] | Arguments to `TyCon`
-> Maybe ([(TyVar, tyco)], Type, [tyco]) | Returns a `TyVar` substitution, the body type of the synonym (not yet substituted) and any arguments remaining from the application

Used to create the view Core has on `TyCon`s. We expand not only closed synonyms like `tcExpandTyCon_maybe`, but also non-recursive `newtype`s

Used to create the view the typechecker has on `TyCon`s. We expand (closed) synonyms only, cf. `coreExpandTyCon_maybe`

coreExpandTyCon_maybe

Arguments

:: TyCon |
-> [tyco] | Arguments to `TyCon`
-> Maybe ([(TyVar, tyco)], Type, [tyco]) | Returns a `TyVar` substitution, the body type of the synonym (not yet substituted) and any arguments remaining from the application

Used to create the view the typechecker has on `TyCon`s. We expand (closed) synonyms only, cf. `coreExpandTyCon_maybe`

makeTyConAbstract :: TyCon -> TyCon

Make an algebraic `TyCon` abstract. Panics if the supplied `TyCon` is not algebraic

newTyConCo :: TyCon -> CoAxiom Unbranched

newTyConCo_maybe :: TyCon -> Maybe (CoAxiom Unbranched)

Extracts the `newtype` coercion from such a `TyCon`, which can be used to construct something with the `newtype`s type from its representation type (right hand side). If the supplied `TyCon` is not a `newtype`, returns `Nothing`

pprPromotionQuote :: TyCon -> SDoc

# Primitive representations of Types

data PrimRep

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.

Constructors

VoidRep |
PtrRep |
IntRep | Signed, word-sized value
WordRep | Unsigned, word-sized value
Int64Rep | Signed, 64 bit value (with 32-bit words only)
Word64Rep | Unsigned, 64 bit value (with 32-bit words only)
AddrRep | A pointer, but not to a Haskell value (use `PtrRep`)
FloatRep |
DoubleRep |
VecRep Int PrimElemRep | A vector

Instances

Eq PrimRep |
Show PrimRep |
Outputable PrimRep |

data PrimElemRep

Constructors

Int8ElemRep |
Int16ElemRep |
Int32ElemRep |
Int64ElemRep |
Word8ElemRep |
Word16ElemRep |
Word32ElemRep |
Word64ElemRep |
FloatElemRep |
DoubleElemRep |

Instances

Eq PrimElemRep |
Show PrimElemRep |
Outputable PrimElemRep |

tyConPrimRep :: TyCon -> PrimRep

Find the primitive representation of a `TyCon`

isVoidRep :: PrimRep -> Bool

isGcPtrRep :: PrimRep -> Bool

primRepSizeW :: DynFlags -> PrimRep -> Int

Find the size of a `PrimRep`, in words

primElemRepSizeB :: PrimElemRep -> Int

# Recursion breaking

data RecTcChecker

initRecTc :: RecTcChecker

checkRecTc :: RecTcChecker -> TyCon -> Maybe RecTcChecker