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

Safe Haskell | None
Language | Haskell2010

Agda.TypeChecking.Records

Synopsis

- orderFields :: QName -> a -> [Name] -> [(Name, a)] -> TCM [a]
- insertMissingFields :: QName -> (Name -> a) -> [FieldAssignment' a] -> [Arg Name] -> TCM [NamedArg a]
- recordModule :: QName -> ModuleName
- getRecordDef :: QName -> TCM Defn
- getRecordOfField :: QName -> TCM (Maybe QName)
- getRecordFieldNames :: QName -> TCM [Arg Name]
- recordFieldNames :: Defn -> [Arg Name]
- findPossibleRecords :: [Name] -> TCM [QName]
- getRecordFieldTypes :: QName -> TCM Telescope
- getRecordTypeFields :: Type -> TCM [Arg QName]
- getRecordConstructor :: QName -> TCM ConHead
- isRecord :: HasConstInfo m => QName -> m (Maybe Defn)
- isRecordType :: Type -> TCM (Maybe (QName, Args, Defn))
- tryRecordType :: Type -> TCM (Either (Maybe Type) (QName, Args, Defn))
- origProjection :: HasConstInfo m => QName -> m (QName, Definition, Maybe Projection)
- getDefType :: QName -> Type -> TCM (Maybe Type)
- projectTyped :: Term -> Type -> ProjOrigin -> QName -> TCM (Maybe (Dom Type, Term, Type))
- isEtaRecord :: HasConstInfo m => QName -> m Bool
- isEtaCon :: HasConstInfo m => QName -> m Bool
- isInductiveRecord :: QName -> TCM Bool
- isEtaRecordType :: Type -> TCM (Maybe (QName, Args))
- isRecordConstructor :: HasConstInfo m => QName -> m (Maybe (QName, Defn))
- isGeneratedRecordConstructor :: QName -> TCM Bool
- unguardedRecord :: QName -> TCM ()
- recursiveRecord :: QName -> TCM ()
- nonRecursiveRecord :: QName -> TCM ()
- isRecursiveRecord :: QName -> TCM Bool
- recRecursive_ :: Defn -> Bool
- etaExpandBoundVar :: Int -> TCM (Maybe (Telescope, Substitution, Substitution))
- expandRecordVar :: Int -> Telescope -> TCM (Maybe (Telescope, Substitution, Substitution, Telescope))
- expandRecordVarsRecursively :: [Int] -> Telescope -> TCM (Telescope, Substitution, Substitution)
- curryAt :: Type -> Int -> TCM (Term -> Term, Term -> Term, Type)
- etaExpandRecord :: QName -> Args -> Term -> TCM (Telescope, Args)
- forceEtaExpandRecord :: QName -> Args -> Term -> TCM (Telescope, Args)
- etaExpandRecord' :: Bool -> QName -> Args -> Term -> TCM (Telescope, Args)
- etaExpandRecord_ :: QName -> Args -> Defn -> Term -> TCM (Telescope, ConHead, ConInfo, Args)
- etaExpandRecord'_ :: Bool -> QName -> Args -> Defn -> Term -> TCM (Telescope, ConHead, ConInfo, Args)
- etaExpandAtRecordType :: Type -> Term -> TCM (Telescope, Term)
- etaContractRecord :: HasConstInfo m => QName -> ConHead -> ConInfo -> Args -> m Term
- isSingletonRecord :: QName -> Args -> TCM (Either MetaId Bool)
- isSingletonRecordModuloRelevance :: QName -> Args -> TCM (Either MetaId Bool)
- isSingletonRecord' :: Bool -> QName -> Args -> TCM (Either MetaId (Maybe Term))
- isSingletonType :: Type -> TCM (Either MetaId (Maybe Term))
- isSingletonTypeModuloRelevance :: MonadTCM tcm => Type -> tcm (Either MetaId Bool)
- isSingletonType' :: Bool -> Type -> TCM (Either MetaId (Maybe Term))
- emap :: (a -> b) -> Either c (Maybe a) -> Either c (Maybe b)
- class NormaliseProjP a where

# Documentation

orderFields :: QName -> a -> [Name] -> [(Name, a)] -> TCM [a] #

Order the fields of a record construction. Use the second argument for missing fields.

insertMissingFields #

Arguments

:: QName | Name of record type (for error reporting).
-> (Name -> a) | Function to generate a placeholder for missing visible field.
-> [FieldAssignment' a] | Given fields.
-> [Arg Name] | All record field names with `ArgInfo`.
-> TCM [NamedArg a] | Given fields enriched by placeholders for missing explicit fields.

A record field assignment `record{xs = es}` might not mention all visible fields. `insertMissingFields` inserts placeholders for the missing visible fields and returns the values in order of the fields in the record declaration.

recordModule :: QName -> ModuleName #

The name of the module corresponding to a record.

getRecordDef :: QName -> TCM Defn #

Get the definition for a record. Throws an exception if the name does not refer to a record or the record is abstract.

getRecordOfField :: QName -> TCM (Maybe QName) #

Get the record name belonging to a field name.

getRecordFieldNames :: QName -> TCM [Arg Name] #

Get the field names of a record.

recordFieldNames :: Defn -> [Arg Name] #

findPossibleRecords :: [Name] -> TCM [QName] #

Find all records with at least the given fields.

getRecordFieldTypes :: QName -> TCM Telescope #

Get the field types of a record.

getRecordTypeFields :: Type -> TCM [Arg QName] #

Get the field names belonging to a record type.

getRecordConstructor :: QName -> TCM ConHead #

Returns the given record type's constructor name (with an empty range).

isRecord :: HasConstInfo m => QName -> m (Maybe Defn) #

Check if a name refers to a record. If yes, return record definition.

isRecordType :: Type -> TCM (Maybe (QName, Args, Defn)) #

Reduce a type and check whether it is a record type. Succeeds only if type is not blocked by a meta var. If yes, return its name, parameters, and definition.

tryRecordType :: Type -> TCM (Either (Maybe Type) (QName, Args, Defn)) #

Reduce a type and check whether it is a record type. Succeeds only if type is not blocked by a meta var. If yes, return its name, parameters, and definition. If no, return the reduced type (unless it is blocked).

origProjection :: HasConstInfo m => QName -> m (QName, Definition, Maybe Projection) #

Get the original projection info for name.

getDefType :: QName -> Type -> TCM (Maybe Type) #

`getDefType f t` computes the type of (possibly projection-(like)) function `f` whose first argument has type `t`. The `parameters` for `f` are extracted from `t`. `Nothing` if `f` is projection(like) but `t` is not a datarecordaxiom type.

Precondition: `t` is reduced.

See also: `getConType`

projectTyped :: Term -> Type -> ProjOrigin -> QName -> TCM (Maybe (Dom Type, Term, Type)) #

The analogue of `piApply`. If `v` is a value of record type `t` with field `f`, then `projectTyped v t f` returns the type of `f v`. And also the record type (as first result).

Works also for projection-like definitions `f`. In this case, the first result is not a record type.

Precondition: `t` is reduced.

isEtaRecord :: HasConstInfo m => QName -> m Bool #

Check if a name refers to an eta expandable record.

isEtaCon :: HasConstInfo m => QName -> m Bool #

isInductiveRecord :: QName -> TCM Bool #

Check if a name refers to a record which is not coinductive. (Projections are then size-preserving)

isEtaRecordType :: Type -> TCM (Maybe (QName, Args)) #

Check if a type is an eta expandable record and return the record identifier and the parameters.

isRecordConstructor :: HasConstInfo m => QName -> m (Maybe (QName, Defn)) #

Check if a name refers to a record constructor. If yes, return record definition.

isGeneratedRecordConstructor :: QName -> TCM Bool #

Check if a constructor name is the internally generated record constructor.

unguardedRecord :: QName -> TCM () #

Mark record type as unguarded. No eta-expansion. Projections do not preserve guardedness.

recursiveRecord :: QName -> TCM () #

Mark record type as recursive. Projections do not preserve guardedness.

nonRecursiveRecord :: QName -> TCM () #

Turn on eta for non-recursive record, unless user declared otherwise.

isRecursiveRecord :: QName -> TCM Bool #

Check whether record type is marked as recursive.

Precondition: record type identifier exists in signature.

recRecursive_ :: Defn -> Bool #

Version of `recRecursive` with proper internal error.

etaExpandBoundVar :: Int -> TCM (Maybe (Telescope, Substitution, Substitution)) #

    etaExpandBoundVar i = (Δ, σ, τ)

Precondition: The current context is `Γ = Γ₁, x:R pars, Γ₂` where `|Γ₂| = i` and `R` is a eta-expandable record type with constructor `c` and fields `Γ'`.

Postcondition: `Δ = Γ₁, Γ', Γ₂[c Γ']` and `Γ ⊢ σ : Δ` and `Δ ⊢ τ : Γ`.

expandRecordVar :: Int -> Telescope -> TCM (Maybe (Telescope, Substitution, Substitution, Telescope)) #

    expandRecordVar i Γ = (Δ, σ, τ, Γ')

Precondition: `Γ = Γ₁, x:R pars, Γ₂` where `|Γ₂| = i` and `R` is a eta-expandable record type with constructor `c` and fields `Γ'`.

Postcondition: `Δ = Γ₁, Γ', Γ₂[c Γ']` and `Γ ⊢ σ : Δ` and `Δ ⊢ τ : Γ`.

expandRecordVarsRecursively :: [Int] -> Telescope -> TCM (Telescope, Substitution, Substitution) #

Precondition: variable list is ordered descendingly. Can be empty.

curryAt :: Type -> Int -> TCM (Term -> Term, Term -> Term, Type) #

    curryAt v (Γ (y : R pars) -> B) n =
         (  v -> λ Γ ys → v Γ (c ys)            {- curry   -}
         ,  v -> λ Γ y → v Γ (p1 y) ... (pm y)  {- uncurry -}
         , Γ (ys : As) → B[c ys / y]
         )

where `n = size Γ`.

etaExpandRecord :: QName -> Args -> Term -> TCM (Telescope, Args) #

`etaExpand r pars u` computes the eta expansion of record value `u` at record type `r pars`.

The first argument `r` should be the name of an eta-expandable record type. Given

    record R : Set where field x : A; y : B; .z : C

and `r : R`,

    etaExpand R [] r = (tel, [R.x r, R.y r, R.z r])

where `tel` is the record telescope instantiated at the parameters `pars`.

forceEtaExpandRecord :: QName -> Args -> Term -> TCM (Telescope, Args) #

Eta expand a record regardless of whether it's an eta-record or not.

etaExpandRecord' :: Bool -> QName -> Args -> Term -> TCM (Telescope, Args) #

etaExpandRecord_ :: QName -> Args -> Defn -> Term -> TCM (Telescope, ConHead, ConInfo, Args) #

etaExpandRecord'_ :: Bool -> QName -> Args -> Defn -> Term -> TCM (Telescope, ConHead, ConInfo, Args) #

etaExpandAtRecordType :: Type -> Term -> TCM (Telescope, Term) #

etaContractRecord :: HasConstInfo m => QName -> ConHead -> ConInfo -> Args -> m Term #

The fields should be eta contracted already.

We can eta contract if all fields `f = ...` are irrelevant or all fields `f` are the projection `f v` of the same value `v`, but we need at least one relevant field to find the value `v`.

TODO: this can be moved out of TCM (but only if ConHead stores also the Arg-decoration of the record fields.

isSingletonRecord :: QName -> Args -> TCM (Either MetaId Bool) #

Is the type a hereditarily singleton record type? May return a blocking metavariable.

Precondition: The name should refer to a record type, and the arguments should be the parameters to the type.

isSingletonRecordModuloRelevance :: QName -> Args -> TCM (Either MetaId Bool) #

isSingletonRecord' :: Bool -> QName -> Args -> TCM (Either MetaId (Maybe Term)) #

Return the unique (closed) inhabitant if exists. In case of counting irrelevance in, the returned inhabitant contains garbage.

isSingletonType :: Type -> TCM (Either MetaId (Maybe Term)) #

Check whether a type has a unique inhabitant and return it. Can be blocked by a metavar.

isSingletonTypeModuloRelevance :: MonadTCM tcm => Type -> tcm (Either MetaId Bool) #

Check whether a type has a unique inhabitant (irrelevant parts ignored). Can be blocked by a metavar.

isSingletonType' :: Bool -> Type -> TCM (Either MetaId (Maybe Term)) #

emap :: (a -> b) -> Either c (Maybe a) -> Either c (Maybe b) #

Auxiliary function.

class NormaliseProjP a where #

Minimal complete definition

normaliseProjP

Methods

normaliseProjP :: HasConstInfo m => a -> m a #

Instances

NormaliseProjP Clause # |
Methods normaliseProjP :: HasConstInfo m => Clause -> m Clause #
NormaliseProjP a => NormaliseProjP [a] # |
Methods normaliseProjP :: HasConstInfo m => [a] -> m [a] #
NormaliseProjP a => NormaliseProjP (Named_ a) # |
Methods normaliseProjP :: HasConstInfo m => Named_ a -> m (Named_ a) #
NormaliseProjP a => NormaliseProjP (Arg a) # |
Methods normaliseProjP :: HasConstInfo m => Arg a -> m (Arg a) #
NormaliseProjP (Pattern' x) # |
Methods normaliseProjP :: HasConstInfo m => Pattern' x -> m (Pattern' x) #