Agda-2.5.2: A dependently typed functional programming language and proof assistant

Safe Haskell | None
Language | Haskell2010

Agda.TypeChecking.Datatypes

Contents

- Constructors
- Data types

Synopsis

- getConHead :: QName -> TCM ConHead
- getConForm :: QName -> TCM ConHead
- getOrigConHead :: QName -> TCM ConHead
- getConstructorData :: HasConstInfo m => QName -> m QName
- getConType :: ConHead -> Type -> TCM (Maybe Type)
- data HasEta
  - = NoEta
  - | YesEta
- data ConstructorInfo
  - = DataCon Nat
  - | RecordCon HasEta [Arg QName]
- getConstructorInfo :: QName -> TCM ConstructorInfo
- getConstructorArity :: QName -> TCM Nat
- isDatatype :: QName -> TCM Bool
- data DataOrRecord
  - = IsData
  - | IsRecord
- isDataOrRecordType :: QName -> TCM (Maybe DataOrRecord)
- isDataOrRecord :: Term -> TCM (Maybe QName)
- getNumberOfParameters :: QName -> TCM (Maybe Nat)
- getConstructors :: QName -> TCM [QName]

# Constructors

getConHead :: QName -> TCM ConHead #

Get true constructor with record fields.

getConForm :: QName -> TCM ConHead #

Get true constructor with fields, expanding literals to constructors if possible.

getOrigConHead :: QName -> TCM ConHead #

Augment constructor with record fields (preserve constructor name). The true constructor might only surface via `reduce`.

getConstructorData :: HasConstInfo m => QName -> m QName #

Get the name of the datatype constructed by a given constructor. Precondition: The argument must refer to a constructor

getConType :: ConHead -> Type -> TCM (Maybe Type) #

`getConType c t` computes the constructor parameters from type `t` and returns the instantiated type of constructor `c`. `Nothing` if `t` is not a data/record type or does not have a constructor `c`. Precondition: `t` is reduced.

data HasEta #

Constructors

NoEta |
YesEta |

Instances

Eq HasEta # |
Methods (==) :: HasEta -> HasEta -> Bool # (/=) :: HasEta -> HasEta -> Bool #

data ConstructorInfo #

Constructors

DataCon Nat |
RecordCon HasEta [Arg QName] |

getConstructorInfo :: QName -> TCM ConstructorInfo #

Return the number of non-parameter arguments to a data constructor, or the field names of a record constructor.

For getting just the arity of constructor `c`, use `either id size $ getConstructorArity c`.

getConstructorArity :: QName -> TCM Nat #

# Data types

isDatatype :: QName -> TCM Bool #

Check if a name refers to a datatype or a record with a named constructor.

data DataOrRecord #

Constructors

IsData |
IsRecord |

Instances

Eq DataOrRecord # |
Methods (==) :: DataOrRecord -> DataOrRecord -> Bool # (/=) :: DataOrRecord -> DataOrRecord -> Bool #
Ord DataOrRecord # |
Methods compare :: DataOrRecord -> DataOrRecord -> Ordering # (<) :: DataOrRecord -> DataOrRecord -> Bool # (<=) :: DataOrRecord -> DataOrRecord -> Bool # (>) :: DataOrRecord -> DataOrRecord -> Bool # (>=) :: DataOrRecord -> DataOrRecord -> Bool # max :: DataOrRecord -> DataOrRecord -> DataOrRecord # min :: DataOrRecord -> DataOrRecord -> DataOrRecord #
Show DataOrRecord # |
Methods showsPrec :: Int -> DataOrRecord -> ShowS # show :: DataOrRecord -> String # showList :: [DataOrRecord] -> ShowS #

isDataOrRecordType :: QName -> TCM (Maybe DataOrRecord) #

Check if a name refers to a datatype or a record.

isDataOrRecord :: Term -> TCM (Maybe QName) #

Precodition: `Term` is `reduce`d.

getNumberOfParameters :: QName -> TCM (Maybe Nat) #

getConstructors :: QName -> TCM [QName] #

Precondition: Name is a data or record type.