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

Safe Haskell | None
Language | Haskell2010

Agda.Syntax.Notation

Description

As a concrete name, a notation is a non-empty list of alternating `IdPart`s and holes. In contrast to concrete names, holes can be binders.

Example: `syntax fmap (λ x → e) xs = for x ∈ xs return e`

The declared notation for `fmap` is `for_∈_return_` where the first hole is a binder.

Synopsis

- data HoleName
  - = LambdaHole {
    - _bindHoleName :: RawName
    - holeName :: RawName
    }
  - | ExprHole {
    - holeName :: RawName
    }
- isLambdaHole :: HoleName -> Bool
- type Notation = [GenPart]
- data GenPart
  - = BindHole !Int
  - | NormalHole (NamedArg Int)
  - | WildHole !Int
  - | IdPart RawName
- stringParts :: Notation -> [RawName]
- holeTarget :: GenPart -> Maybe Int
- isAHole :: GenPart -> Bool
- isNormalHole :: GenPart -> Bool
- isBindingHole :: GenPart -> Bool
- data NotationKind
  - = InfixNotation
  - | PrefixNotation
  - | PostfixNotation
  - | NonfixNotation
  - | NoNotation
- notationKind :: Notation -> NotationKind
- mkNotation :: [NamedArg HoleName] -> [RawName] -> Either String Notation
- noNotation :: Notation

# Documentation

data HoleName #

Data type constructed in the Happy parser; converted to `GenPart` before it leaves the Happy code.

Constructors

LambdaHole | `x -> y`; 1st argument is the bound name (unused for now).
Fields _bindHoleName :: RawName holeName :: RawName
ExprHole | Simple named hole with hiding.
Fields holeName :: RawName

isLambdaHole :: HoleName -> Bool #

Is the hole a binder?

type Notation = [GenPart] #

Notation as provided by the `syntax` declaration.

data GenPart #

Part of a Notation

Constructors

BindHole !Int | Argument is the position of the hole (with binding) where the binding should occur.
NormalHole (NamedArg Int) | Argument is where the expression should go.
WildHole !Int | An underscore in binding position.
IdPart RawName |

Instances

Eq GenPart # |
Methods (==) :: GenPart -> GenPart -> Bool # (/=) :: GenPart -> GenPart -> Bool #
Ord GenPart # |
Methods compare :: GenPart -> GenPart -> Ordering # (<) :: GenPart -> GenPart -> Bool # (<=) :: GenPart -> GenPart -> Bool # (>) :: GenPart -> GenPart -> Bool # (>=) :: GenPart -> GenPart -> Bool # max :: GenPart -> GenPart -> GenPart # min :: GenPart -> GenPart -> GenPart #
Show GenPart # |
Methods showsPrec :: Int -> GenPart -> ShowS # show :: GenPart -> String # showList :: [GenPart] -> ShowS #
NFData GenPart # |
Methods rnf :: GenPart -> () #
KillRange GenPart # |
Methods killRange :: KillRangeT GenPart #

stringParts :: Notation -> [RawName] #

Get a flat list of identifier parts of a notation.

holeTarget :: GenPart -> Maybe Int #

Target argument position of a part (Nothing if it is not a hole).

isAHole :: GenPart -> Bool #

Is the part a hole? WildHoles don't count since they don't correspond to anything the user writes.

isNormalHole :: GenPart -> Bool #

Is the part a normal hole?

isBindingHole :: GenPart -> Bool #

Is the part a binder?

data NotationKind #

Classification of notations.

Constructors

InfixNotation | Ex: `_bla_blub_`.
PrefixNotation | Ex: `_bla_blub`.
PostfixNotation | Ex: `bla_blub_`.
NonfixNotation | Ex: `bla_blub`.
NoNotation |

Instances

Eq NotationKind # |
Methods (==) :: NotationKind -> NotationKind -> Bool # (/=) :: NotationKind -> NotationKind -> Bool #
Show NotationKind # |
Methods showsPrec :: Int -> NotationKind -> ShowS # show :: NotationKind -> String # showList :: [NotationKind] -> ShowS #

notationKind :: Notation -> NotationKind #

Classify a notation by presence of leading and/or trailing normal holes.

mkNotation :: [NamedArg HoleName] -> [RawName] -> Either String Notation #

From notation with names to notation with indices.

Example: `ids = ["for", "x", "∈", "xs", "return", "e"] holes = [ LambdaHole "x" "e", ExprHole "xs" ]` creates the notation `[ IdPart "for" , BindHole 0 , IdPart "∈" , NormalHole 1 , IdPart "return" , NormalHole 0 ]`

noNotation :: Notation #