HORIZON HASKELLDocslts/ghc-9.14.x3e2d5682026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 3e2d568 · 2026-10-11

ModuleAgda-2.8.0.2Haskell2010

Agda.TypeChecking.Records

  • 1 type
  • 1 class
  • 57 values
  • PackageAgda-2.8.0.2
  • Exports59
  • LanguageHaskell2010
  • LicenceMIT
  • SourceRecords.hs

Tools to build record values

9 declarations
valueorderFields
  1. :: HasRange a
  2. => QName

    Name of record type (for error message).

  3. -> (Arg Name -> a)

    How to fill a missing field.

  4. -> [Arg Name]

    Field names of the record type.

  5. -> [(Name, a)]

    Provided fields with content in the record expression.

  6. -> Writer [RecordFieldWarning] [a]

    Content arranged in official order.

#

Order the fields of a record construction.

valueorderFieldsWarn
  1. :: HasRange a
  2. => QName

    Name of record type (for error message).

  3. -> (Arg Name -> a)

    How to fill a missing field.

  4. -> [Arg Name]

    Field names of the record type.

  5. -> [(Name, a)]

    Provided fields with content in the record expression.

  6. -> TCM [a]

    Content arranged in official order.

#

Order the fields of a record construction. Raise generated RecordFieldWarnings as warnings.

valueorderFieldsFail
  1. :: HasRange a
  2. => QName

    Name of record type (for error message).

  3. -> (Arg Name -> a)

    How to fill a missing field.

  4. -> [Arg Name]

    Field names of the record type.

  5. -> [(Name, a)]

    Provided fields with content in the record expression.

  6. -> TCM [a]

    Content arranged in official order.

#

Order the fields of a record construction. Raise generated RecordFieldWarnings as errors.

valueinsertMissingFields
  1. :: HasRange a
  2. => QName

    Name of record type (for error reporting).

  3. -> (Name -> a)

    Function to generate a placeholder for missing visible field.

  4. -> [FieldAssignment' a]

    Given fields.

  5. -> [Arg Name]

    All record field names with ArgInfo.

  6. -> Writer [RecordFieldWarning] [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.

valueinsertMissingFieldsWarn
  1. :: HasRange a
  2. => QName

    Name of record type (for error reporting).

  3. -> (Name -> a)

    Function to generate a placeholder for missing visible field.

  4. -> [FieldAssignment' a]

    Given fields.

  5. -> [Arg Name]

    All record field names with ArgInfo.

  6. -> 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.

valueinsertMissingFieldsFail
  1. :: HasRange a
  2. => QName

    Name of record type (for error reporting).

  3. -> (Name -> a)

    Function to generate a placeholder for missing visible field.

  4. -> [FieldAssignment' a]

    Given fields.

  5. -> [Arg Name]

    All record field names with ArgInfo.

  6. -> 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.

Query information about records from signature

50 declarations
valueisRecordType :: PureTCM m => Type -> m (Maybe (QName, Args, RecordData))
#

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.

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).

valuegetDefType :: PureTCM m => QName -> Type -> m (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

valueprojectTyped
  1. :: PureTCM m
  2. => Term

    Head (record value).

  3. -> Type

    Its type.

  4. -> ProjOrigin
  5. -> QName

    Projection.

  6. -> m (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.

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

Check if a name refers to an eta expandable record.

The answer is no for a record type with an erased constructor unless the current quantity is "erased".

valueupdateEtaForRecord :: QName -> TCM ()
#

Turn on eta for non-recursive and inductive guarded recursive records, unless user declared otherwise. Projections do not preserve guardedness.

valuerecursiveRecord :: QName -> TCM ()
#

Turn on eta for inductive guarded recursive records. Projections do not preserve guardedness.

Check whether record type is marked as recursive.

Precondition: record type identifier exists in signature.

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 Δ ⊢ τ : Γ.

valuecurryAt :: 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 Γ.

valueetaExpandRecord
  1. :: (HasConstInfo m, MonadDebug m, ReadTCState m)
  2. => QName

    Name of record type.

  3. -> Args

    Parameters applied to record type.

  4. -> Term

    Term to eta-expand.

  5. -> m (Telescope, Args)

    Field types instantiated to parameters, field values.

#

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.

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.

If all fields are erased, we cannot eta-contract.

valueisSingletonRecord
  1. :: (PureTCM m, MonadBlock m)
  2. => QName

    Name of record type to check.

  3. -> Args

    Parameters given to the record type.

  4. -> m 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.

valueisSingletonRecord'
  1. :: (PureTCM m, MonadBlock m)
  2. => Bool

    Should disregard irrelevant fields?

  3. -> QName

    Name of record type to check.

  4. -> Args

    Parameters given to the record type.

  5. -> Set QName

    Non-terminating record types we already encountered. These are considered as non-singletons, otherwise we would construct an infinite inhabitant (in an infinite time...).

  6. -> m (Maybe Term)

    The unique inhabitant, if any. May contain dummy terms in irrelevant positions.

#

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

valueisSingletonType'
  1. :: (PureTCM m, MonadBlock m)
  2. => Bool

    Should disregard irrelevant fields?

  3. -> Type

    Type to check.

  4. -> Set QName

    Non-terminating record typess we already encountered. These are considered as non-singletons, otherwise we would construct an infinite inhabitant (in an infinite time...).

  5. -> m (Maybe Term)

    The unique inhabitant, if any. May contain dummy terms in irrelevant positions.

#
valueisEtaVar :: PureTCM m => Term -> Type -> m (Maybe Int)
#

Checks whether the given term (of the given type) is beta-eta-equivalent to a variable. Returns just the de Bruijn-index of the variable if it is, or nothing otherwise.

classclass NormaliseProjP a where
#

Replace projection patterns by the original projections.

Methods

Instances5NormaliseProjP