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

Safe Haskell | None
Language | Haskell2010

Agda.Syntax.Concrete.Name

Contents

- Operations on `Name` and `NamePart`
- Operations on qualified names
- Operations on `TopLevelModuleName`
- No name stuff
- Showing names
- Printing names
- Range instances
- NFData instances

Description

Names in the concrete syntax are just strings (or lists of strings for qualified names).

Synopsis

- data Name
  - = Name Range [NamePart]
  - | NoName Range NameId
- data NamePart
  - = Hole
  - | Id RawName
- data QName
  - = Qual Name QName
  - | QName Name
- newtype TopLevelModuleName = TopLevelModuleName {
  - moduleNameParts :: [String]
  }
- nameToRawName :: Name -> RawName
- nameParts :: Name -> [NamePart]
- nameStringParts :: Name -> [RawName]
- stringNameParts :: String -> [NamePart]
- class NumHoles a where
- isOperator :: Name -> Bool
- isHole :: NamePart -> Bool
- isPrefix :: Name -> Bool
- isPostfix :: Name -> Bool
- isInfix :: Name -> Bool
- isNonfix :: Name -> Bool
- qualify :: QName -> Name -> QName
- unqualify :: QName -> Name
- qnameParts :: QName -> [Name]
- toTopLevelModuleName :: QName -> TopLevelModuleName
- fromTopLevelModuleName :: TopLevelModuleName -> QName
- moduleNameToFileName :: TopLevelModuleName -> String -> FilePath
- projectRoot :: AbsolutePath -> TopLevelModuleName -> AbsolutePath
- noName_ :: Name
- noName :: Range -> Name
- class IsNoName a where

# Documentation

data Name #

A name is a non-empty list of alternating `Id`s and `Hole`s. A normal name is represented by a singleton list, and operators are represented by a list with `Hole`s where the arguments should go. For instance: `[Hole,Id "+",Hole]` is infix addition.

Equality and ordering on `Name`s are defined to ignore range so same names in different locations are equal.

Constructors

Name Range [NamePart] | A (mixfix) identifier.
NoName Range NameId | `_`.

Instances

Eq Name # | Define equality on `Name` to ignore range so same names in different locations are equal. Is there a reason not to do this? -Jeff No. But there are tons of reasons to do it. For instance, when using names as keys in maps you really don't want to have to get the range right to be able to do a lookup. -Ulf
Methods (==) :: Name -> Name -> Bool # (/=) :: Name -> Name -> Bool #
Ord Name # |
Methods compare :: Name -> Name -> Ordering # (<) :: Name -> Name -> Bool # (<=) :: Name -> Name -> Bool # (>) :: Name -> Name -> Bool # (>=) :: Name -> Name -> Bool # max :: Name -> Name -> Name # min :: Name -> Name -> Name #
Show Name # |
Methods showsPrec :: Int -> Name -> ShowS # show :: Name -> String # showList :: [Name] -> ShowS #
NFData Name # | Ranges are not forced.
Methods rnf :: Name -> () #
Pretty Name # |
Methods pretty :: Name -> Doc # prettyPrec :: Int -> Name -> Doc #
KillRange Name # |
Methods killRange :: KillRangeT Name #
SetRange Name # |
Methods setRange :: Range -> Name -> Name #
HasRange Name # |
Methods getRange :: Name -> Range #
Underscore Name # |
Methods underscore :: Name # isUnderscore :: Name -> Bool #
IsNoName Name # |
Methods isNoName :: Name -> Bool #
NumHoles Name # |
Methods numHoles :: Name -> Int #
ExprLike Name # |
Methods mapExpr :: (Expr -> Expr) -> Name -> Name # traverseExpr :: Monad m => (Expr -> m Expr) -> Name -> m Name # foldExpr :: Monoid m => (Expr -> m) -> Name -> m #
SubstExpr Name # |
Methods substExpr :: [(Name, Expr)] -> Name -> Name #
PrettyTCM Name # |
Methods prettyTCM :: Name -> TCM Doc #
ToConcrete Name Name # |
Methods toConcrete :: Name -> AbsToCon Name # bindToConcrete :: Name -> (Name -> AbsToCon b) -> AbsToCon b #
ToAbstract (NewName Name) Name # |
Methods toAbstract :: NewName Name -> ScopeM Name #
ToConcrete (Maybe QName) (Maybe Name) # |
Methods toConcrete :: Maybe QName -> AbsToCon (Maybe Name) # bindToConcrete :: Maybe QName -> (Maybe Name -> AbsToCon b) -> AbsToCon b #

data NamePart #

Mixfix identifiers are composed of words and holes, e.g. `_+_` or `if_then_else_` or `[_/_]`.

Constructors

Hole | `_` part.
Id RawName | Identifier part.

Instances

Eq NamePart # |
Methods (==) :: NamePart -> NamePart -> Bool # (/=) :: NamePart -> NamePart -> Bool #
Ord NamePart # |
Methods compare :: NamePart -> NamePart -> Ordering # (<) :: NamePart -> NamePart -> Bool # (<=) :: NamePart -> NamePart -> Bool # (>) :: NamePart -> NamePart -> Bool # (>=) :: NamePart -> NamePart -> Bool # max :: NamePart -> NamePart -> NamePart # min :: NamePart -> NamePart -> NamePart #
Show NamePart # |
Methods showsPrec :: Int -> NamePart -> ShowS # show :: NamePart -> String # showList :: [NamePart] -> ShowS #
Generic NamePart # |
Associated Types type Rep NamePart :: * -> * # Methods from :: NamePart -> Rep NamePart x # to :: Rep NamePart x -> NamePart #
NFData NamePart # |
Methods rnf :: NamePart -> () #
Pretty NamePart # |
Methods pretty :: NamePart -> Doc # prettyPrec :: Int -> NamePart -> Doc #
NumHoles [NamePart] # |
Methods numHoles :: [NamePart] -> Int #
type Rep NamePart # |
type Rep NamePart = D1 (MetaData "NamePart" "Agda.Syntax.Concrete.Name" "Agda-2.5.2-BvXz1IFuA8Y7bbv0poFInq" False) ((:+:) (C1 (MetaCons "Hole" PrefixI False) U1) (C1 (MetaCons "Id" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 RawName))))

data QName #

`QName` is a list of namespaces and the name of the constant. For the moment assumes namespaces are just `Name`s and not explicitly applied modules. Also assumes namespaces are generative by just using derived equality. We will have to define an equality instance to non-generative namespaces (as well as having some sort of lookup table for namespace names).

Constructors

Qual Name QName | `A.rest`.
QName Name | `x`.

Instances

Eq QName # |
Methods (==) :: QName -> QName -> Bool # (/=) :: QName -> QName -> Bool #
Ord QName # |
Methods compare :: QName -> QName -> Ordering # (<) :: QName -> QName -> Bool # (<=) :: QName -> QName -> Bool # (>) :: QName -> QName -> Bool # (>=) :: QName -> QName -> Bool # max :: QName -> QName -> QName # min :: QName -> QName -> QName #
Show QName # |
Methods showsPrec :: Int -> QName -> ShowS # show :: QName -> String # showList :: [QName] -> ShowS #
NFData QName # |
Methods rnf :: QName -> () #
Pretty QName # |
Methods pretty :: QName -> Doc # prettyPrec :: Int -> QName -> Doc #
KillRange QName # |
Methods killRange :: KillRangeT QName #
SetRange QName # |
Methods setRange :: Range -> QName -> QName #
HasRange QName # |
Methods getRange :: QName -> Range #
Underscore QName # |
Methods underscore :: QName # isUnderscore :: QName -> Bool #
IsNoName QName # |
Methods isNoName :: QName -> Bool #
NumHoles QName # |
Methods numHoles :: QName -> Int #
ExprLike QName # |
Methods mapExpr :: (Expr -> Expr) -> QName -> QName # traverseExpr :: Monad m => (Expr -> m Expr) -> QName -> m QName # foldExpr :: Monoid m => (Expr -> m) -> QName -> m #
PrettyTCM QName # |
Methods prettyTCM :: QName -> TCM Doc #
ToConcrete ModuleName QName # |
Methods toConcrete :: ModuleName -> AbsToCon QName # bindToConcrete :: ModuleName -> (QName -> AbsToCon b) -> AbsToCon b #
ToConcrete QName QName # |
Methods toConcrete :: QName -> AbsToCon QName # bindToConcrete :: QName -> (QName -> AbsToCon b) -> AbsToCon b #

newtype TopLevelModuleName #

Top-level module names. Used in connection with the file system.

Invariant: The list must not be empty.

Constructors

TopLevelModuleName |
Fields moduleNameParts :: [String]

Instances

Eq TopLevelModuleName # |
Methods (==) :: TopLevelModuleName -> TopLevelModuleName -> Bool # (/=) :: TopLevelModuleName -> TopLevelModuleName -> Bool #
Ord TopLevelModuleName # |
Methods compare :: TopLevelModuleName -> TopLevelModuleName -> Ordering # (<) :: TopLevelModuleName -> TopLevelModuleName -> Bool # (<=) :: TopLevelModuleName -> TopLevelModuleName -> Bool # (>) :: TopLevelModuleName -> TopLevelModuleName -> Bool # (>=) :: TopLevelModuleName -> TopLevelModuleName -> Bool # max :: TopLevelModuleName -> TopLevelModuleName -> TopLevelModuleName # min :: TopLevelModuleName -> TopLevelModuleName -> TopLevelModuleName #
Show TopLevelModuleName # |
Methods showsPrec :: Int -> TopLevelModuleName -> ShowS # show :: TopLevelModuleName -> String # showList :: [TopLevelModuleName] -> ShowS #
Pretty TopLevelModuleName # |
Methods pretty :: TopLevelModuleName -> Doc # prettyPrec :: Int -> TopLevelModuleName -> Doc #
Sized TopLevelModuleName # |
Methods size :: Integral n => TopLevelModuleName -> n #

# Operations on `Name` and `NamePart`

nameToRawName :: Name -> RawName #

nameParts :: Name -> [NamePart] #

nameStringParts :: Name -> [RawName] #

stringNameParts :: String -> [NamePart] #

Parse a string to parts of a concrete name.

Note: `stringNameParts "_" == [Id "_"] == nameParts NoName{}`

class NumHoles a where #

Number of holes in a `Name` (i.e., arity of a mixfix-operator).

Minimal complete definition

numHoles

Methods

numHoles :: a -> Int #

Instances

NumHoles QName # |
Methods numHoles :: QName -> Int #
NumHoles Name # |
Methods numHoles :: Name -> Int #
NumHoles AmbiguousQName # | We can have an instance for ambiguous names as all share a common concrete name.
Methods numHoles :: AmbiguousQName -> Int #
NumHoles QName # |
Methods numHoles :: QName -> Int #
NumHoles Name # |
Methods numHoles :: Name -> Int #
NumHoles [NamePart] # |
Methods numHoles :: [NamePart] -> Int #

isOperator :: Name -> Bool #

Is the name an operator?

isHole :: NamePart -> Bool #

isPrefix :: Name -> Bool #

isPostfix :: Name -> Bool #

isInfix :: Name -> Bool #

isNonfix :: Name -> Bool #

# Operations on qualified names

qualify :: QName -> Name -> QName #

    qualify A.B x == A.B.x

unqualify :: QName -> Name #

    unqualify A.B.x == x

The range is preserved.

qnameParts :: QName -> [Name] #

    qnameParts A.B.x = [A, B, x]

# Operations on `TopLevelModuleName`

toTopLevelModuleName :: QName -> TopLevelModuleName #

Turns a qualified name into a `TopLevelModuleName`. The qualified name is assumed to represent a top-level module name.

fromTopLevelModuleName :: TopLevelModuleName -> QName #

Turns a top level module into a qualified name with `noRange`.

moduleNameToFileName :: TopLevelModuleName -> String -> FilePath #

Turns a top-level module name into a file name with the given suffix.

projectRoot :: AbsolutePath -> TopLevelModuleName -> AbsolutePath #

Finds the current project's "root" directory, given a project file and the corresponding top-level module name.

Example: If the module "A.B.C" is located in the file "fooABC.agda", then the root is "foo".

Precondition: The module name must be well-formed.

# No name stuff

noName_ :: Name #

    noName_ = noName noRange

noName :: Range -> Name #

class IsNoName a where #

Check whether a name is the empty name "_".

Minimal complete definition

isNoName

Methods

isNoName :: a -> Bool #

Instances

IsNoName String # |
Methods isNoName :: String -> Bool #
IsNoName ByteString # |
Methods isNoName :: ByteString -> Bool #
IsNoName QName # |
Methods isNoName :: QName -> Bool #
IsNoName Name # |
Methods isNoName :: Name -> Bool #
IsNoName Name # | An abstract name is empty if its concrete name is empty.
Methods isNoName :: Name -> Bool #

# Showing names

# Printing names

# Range instances

# NFData instances