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

Safe HaskellNone

Agda.Syntax.Concrete

Contents

Description

The concrete syntax is a raw representation of the program text without any desugaring at all. This is what the parser produces. The idea is that if we figure out how to keep the concrete syntax around, it can be printed exactly as the user wrote it.

Synopsis

Expressions

data Expr Source

Concrete expressions. Should represent exactly what the user wrote.

Constructors

Ident QName

ex: x

Lit Literal

ex: 1 or "foo"

QuestionMark !Range (Maybe Nat)

ex: ? or {! ... !}

Underscore !Range (Maybe String)

ex: _ or _A_5

RawApp !Range [Expr]

before parsing operators

App !Range Expr (NamedArg Expr)

ex: e e, e {e}, or e {x = e}

OpApp !Range QName [NamedArg (OpApp Expr)]

ex: e + e

WithApp !Range Expr [Expr]

ex: e | e1 | .. | en

HiddenArg !Range (Named_ Expr)

ex: {e} or {x=e}

InstanceArg !Range (Named_ Expr)

ex: {{e}} or {{x=e}}

Lam !Range [LamBinding] Expr

ex: \x {y} -> e or \(x:A){y:B} -> e

AbsurdLam !Range Hiding

ex: \ ()

ExtendedLam !Range [(LHS, RHS, WhereClause)]

ex: \ { p11 .. p1a -> e1 ; .. ; pn1 .. pnz -> en }

Fun !Range Expr Expr

ex: e -> e or .e -> e (NYI: {e} -> e)

Pi Telescope Expr

ex: (xs:e) -> e or {xs:e} -> e

Set !Range

ex: Set

Prop !Range

ex: Prop

SetN !Range Integer

ex: Set0, Set1, ..

Rec !Range [(Name, Expr)]

ex: record {x = a; y = b}

RecUpdate !Range Expr [(Name, Expr)]

ex: record e {x = a; y = b}

Let !Range [Declaration] Expr

ex: let Ds in e

Paren !Range Expr

ex: (e)

Absurd !Range

ex: () or {}, only in patterns

As !Range Name Expr

ex: x@p, only in patterns

Dot !Range Expr

ex: .p, only in patterns

ETel Telescope

only used for printing telescopes

QuoteGoal !Range Name Expr

ex: quoteGoal x in e

QuoteContext !Range Name Expr

ex: quoteContext ctx in e

Quote !Range

ex: quote, should be applied to a name

QuoteTerm !Range

ex: quoteTerm, should be applied to a term

Tactic !Range Expr [Expr]
tactic solve | subgoal1 | .. | subgoalN
Unquote !Range

ex: unquote, should be applied to a term of type Term

DontCare Expr

to print irrelevant things

Equal !Range Expr Expr

ex: a = b, used internally in the parser

data OpApp e Source

Constructors

SyntaxBindingLambda !Range [LamBinding] e

an abstraction inside a special syntax declaration (see Issue 358 why we introduce this).

Ordinary e 

Instances

Functor OpApp 
Typeable1 OpApp 
Foldable OpApp 
Traversable OpApp 
Pretty (OpApp Expr) 
KillRange e => KillRange (OpApp e) 
HasRange e => HasRange (OpApp e) 
ExprLike a => ExprLike (OpApp a) 

fromOrdinary :: e -> OpApp e -> eSource

data AppView Source

The Expr is not an application.

Constructors

AppView Expr [NamedArg Expr] 

Bindings

type LamBinding = LamBinding' TypedBindingsSource

A lambda binding is either domain free or typed.

data LamBinding' a Source

Constructors

DomainFree ArgInfo BoundName

. x or {x} or .x or .{x} or {.x}

DomainFull a

. (xs : e) or {xs : e}

type TypedBindings = TypedBindings' TypedBindingSource

A sequence of typed bindings with hiding information. Appears in dependent function spaces, typed lambdas, and telescopes.

type TypedBinding = TypedBinding' ExprSource

A typed binding.

data ColoredTypedBinding Source

Color a TypeBinding. Used by Pretty.

Constructors

WithColors [Color] TypedBinding 

data BoundName Source

Constructors

BName 

Fields

boundName :: Name
 
boundLabel :: Name

for implicit function types the label matters and can't be alpha-renamed

bnameFixity :: Fixity'
 

type Telescope = [TypedBindings]Source

A telescope is a sequence of typed bindings. Bound variables are in scope in later types.

Declarations

data Declaration Source

The representation type of a declaration. The comments indicate which type in the intended family the constructor targets.

Constructors

TypeSig ArgInfo Name Expr

Axioms and functions can be irrelevant. (Hiding should be NotHidden)

Field Name (Arg Expr)

Record field, can be hidden and/or irrelevant.

FunClause LHS RHS WhereClause 
DataSig !Range Induction Name [LamBinding] Expr

lone data signature in mutual block

Data !Range Induction Name [LamBinding] (Maybe Expr) [Constructor] 
RecordSig !Range Name [LamBinding] Expr

lone record signature in mutual block

Record !Range Name (Maybe (Ranged Induction)) (Maybe Name) [LamBinding] (Maybe Expr) [Declaration]

The optional name is a name for the record constructor.

Infix Fixity [Name] 
Syntax Name Notation

notation declaration for a name

PatternSyn !Range Name [Arg Name] Pattern 
Mutual !Range [Declaration] 
Abstract !Range [Declaration] 
Private !Range [Declaration] 
InstanceB !Range [Declaration] 
Postulate !Range [TypeSignatureOrInstanceBlock] 
Primitive !Range [TypeSignature] 
Open !Range QName ImportDirective 
Import !Range QName (Maybe AsName) OpenShortHand ImportDirective 
ModuleMacro !Range Name ModuleApplication OpenShortHand ImportDirective 
Module !Range QName [TypedBindings] [Declaration] 
UnquoteDecl !Range Name Expr 
Pragma Pragma 

type TypeSignature = DeclarationSource

Just type signatures.

type TypeSignatureOrInstanceBlock = DeclarationSource

Just type signatures or instance blocks.

type Constructor = TypeSignatureSource

A data constructor declaration is just a type signature.

data ImportDirective Source

The things you are allowed to say when you shuffle names between name spaces (i.e. in import, namespace, or open declarations).

Constructors

ImportDirective 

Fields

importDirRange :: !Range
 
usingOrHiding :: UsingOrHiding
 
renaming :: [Renaming]
 
publicOpen :: Bool

Only for open. Exports the opened names from the current module.

data ImportedName Source

An imported name can be a module or a defined name

Constructors

ImportedModule 

Fields

importedName :: Name
 
ImportedName 

Fields

importedName :: Name
 

data Renaming Source

Constructors

Renaming 

Fields

renFrom :: ImportedName

Rename from this name.

renTo :: Name

To this one.

renToRange :: Range

The range of the "to" keyword. Retained for highlighting purposes.

data AsName Source

Constructors

AsName 

Fields

asName :: Name

The "as" name.

asRange :: Range

The range of the "as" keyword. Retained for highlighting purposes.

Instances

defaultImportDir :: ImportDirectiveSource

Default is directive is private (use everything, but do not export).

data LHS Source

Left hand sides can be written in infix style. For example:

 n + suc m = suc (n + m)
 (f ∘ g) x = f (g x)

We use fixity information to see which name is actually defined.

Constructors

LHS

original pattern, with-patterns, rewrite equations and with-expressions

Fields

lhsOriginalPattern :: Pattern
f ps
lhsWithPattern :: [Pattern]

| p (many)

lhsRewriteEqn :: [RewriteEqn]

rewrite e (many)

lhsWithExpr :: [WithExpr]

with e (many)

Ellipsis Range [Pattern] [RewriteEqn] [WithExpr]

new with-patterns, rewrite equations and with-expressions

data Pattern Source

Concrete patterns. No literals in patterns at the moment.

Constructors

IdentP QName

c or x

QuoteP !Range
quote
AppP Pattern (NamedArg Pattern)

p p' or p {x = p'}

RawAppP !Range [Pattern]

p1..pn before parsing operators

OpAppP !Range QName [NamedArg Pattern]

eg: p => p' for operator _=>_

HiddenP !Range (Named_ Pattern)

{p} or {x = p}

InstanceP !Range (Named_ Pattern)

{{p}} or {{x = p}}

ParenP !Range Pattern
(p)
WildP !Range
_
AbsurdP !Range
()
AsP !Range Name Pattern

x@p unused

DotP !Range Expr
.e
LitP Literal

0, 1, etc.

data LHSCore Source

Processed (scope-checked) intermediate form of the core f ps of LHS. Corresponds to lhsOriginalPattern.

Constructors

LHSHead 
LHSProj 

Fields

lhsDestructor :: QName

record projection identifier

lhsPatsLeft :: [NamedArg Pattern]

side patterns

lhsFocus :: NamedArg LHSCore

main branch

lhsPatsRight :: [NamedArg Pattern]

side patterns

data RHS' e Source

Constructors

AbsurdRHS

No right hand side because of absurd match.

RHS e 

Instances

Functor RHS' 
Show RHS 
Typeable1 RHS' 
Foldable RHS' 
Traversable RHS' 
Pretty RHS 
KillRange RHS 
HasRange RHS 
ToAbstract RHS AbstractRHS 
ToConcrete RHS (RHS, [Expr], [Expr], [Declaration]) 
ExprLike a => ExprLike (RHS' a) 

data WhereClause' decls Source

Constructors

NoWhere

No where clauses.

AnyWhere decls

Ordinary where.

SomeWhere Name decls

Named where: module M where.

type Module = ([Pragma], [Declaration])Source

Modules: Top-level pragmas plus other top-level declarations.

data ThingWithFixity x Source

Constructors

ThingWithFixity x Fixity' 

Instances

topLevelModuleName :: Module -> TopLevelModuleNameSource

Computes the top-level module name.

Precondition: The Module has to be well-formed.

Pattern tools

patternHead :: Pattern -> Maybe NameSource

Get the leftmost symbol in a pattern.

patternNames :: Pattern -> [Name]Source

Get all the identifiers in a pattern in left-to-right order.

Concrete instances

type Arg a = Arg Color aSource