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

Safe Haskell | None
Language | Haskell2010

Agda.Syntax.Abstract.Name

Contents

- Important instances: Eq, Ord, Hashable
- IsNoName instances (checking for "_")
- Show instances
- Pretty instances
- Range instances
  - HasRange
  - SetRange
  - KillRange
- Sized instances
- NFData instances

Description

Abstract names carry unique identifiers and stuff.

Synopsis

- data Name = Name {
  - nameId :: !NameId
  - nameConcrete :: Name
  - nameBindingSite :: Range
  - nameFixity :: Fixity'
  }
- data QName = QName {
  - qnameModule :: ModuleName
  - qnameName :: Name
  }
- data QNamed a = QNamed {
  - qname :: QName
  - qnamed :: a
  }
- newtype ModuleName = MName {
  - mnameToList :: [Name]
  }
- newtype AmbiguousQName = AmbQ {
  - unAmbQ :: [QName]
  }
- class IsProjP a where
- isAnonymousModuleName :: ModuleName -> Bool
- withRangesOf :: ModuleName -> [Name] -> ModuleName
- withRangesOfQ :: ModuleName -> QName -> ModuleName
- mnameFromList :: [Name] -> ModuleName
- noModuleName :: ModuleName
- commonParentModule :: ModuleName -> ModuleName -> ModuleName
- class MkName a where
- qnameToList :: QName -> [Name]
- qnameFromList :: [Name] -> QName
- qnameToMName :: QName -> ModuleName
- mnameToQName :: ModuleName -> QName
- showQNameId :: QName -> String
- qnameToConcrete :: QName -> QName
- mnameToConcrete :: ModuleName -> QName
- toTopLevelModuleName :: ModuleName -> TopLevelModuleName
- qualifyM :: ModuleName -> ModuleName -> ModuleName
- qualifyQ :: ModuleName -> QName -> QName
- qualify :: ModuleName -> Name -> QName
- qualify_ :: Name -> QName
- isOperator :: QName -> Bool
- isSubModuleOf :: ModuleName -> ModuleName -> Bool
- isInModule :: QName -> ModuleName -> Bool
- nextName :: Name -> Name
- class IsNoName a where

# Documentation

data Name #

A name is a unique identifier and a suggestion for a concrete name. The concrete name contains the source location (if any) of the name. The source location of the binding site is also recorded.

Constructors

Name |
Fields nameId :: !NameId nameConcrete :: Name nameBindingSite :: Range nameFixity :: Fixity'

Instances

Eq Name # |
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 # | Only use this `show` function in debugging! To convert an abstract `Name` into a string use `prettyShow`.
Methods showsPrec :: Int -> Name -> ShowS # show :: Name -> String # showList :: [Name] -> ShowS #
NFData Name # | The range is not forced.
Methods rnf :: Name -> () #
Hashable Name # |
Methods hashWithSalt :: Int -> Name -> Int # hash :: Name -> Int #
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 #
IsNoName Name # | An abstract name is empty if its concrete name is empty.
Methods isNoName :: Name -> Bool #
NumHoles Name # |
Methods numHoles :: Name -> Int #
AddContext Name # |
Methods addContext :: MonadTCM tcm => Name -> tcm a -> tcm a # contextSize :: Name -> Nat #
PrettyTCM Name # |
Methods prettyTCM :: Name -> TCM Doc #
InstantiateFull Name # |
Methods instantiateFull' :: Name -> ReduceM Name #
ToConcrete Name Name # |
Methods toConcrete :: Name -> AbsToCon Name # bindToConcrete :: Name -> (Name -> AbsToCon b) -> AbsToCon b #
Reify Name Name # |
Methods reify :: Name -> TCM Name # reifyWhen :: Bool -> Name -> TCM Name #
Suggest Name (Abs b) # |
Methods suggest :: Name -> Abs b -> String #
ToAbstract Pattern (Names, Pattern) # |
Methods toAbstract :: Pattern -> WithNames (Names, Pattern) #
AddContext (Dom (Name, Type)) # |
Methods addContext :: MonadTCM tcm => Dom (Name, Type) -> tcm a -> tcm a # contextSize :: Dom (Name, Type) -> Nat #
ToAbstract (NewName Name) Name # |
Methods toAbstract :: NewName Name -> ScopeM Name #
ToAbstract (NewName BoundName) Name # |
Methods toAbstract :: NewName BoundName -> ScopeM Name #
ToAbstract r a => ToAbstract (Abs r) (a, Name) # |
Methods toAbstract :: Abs r -> WithNames (a, Name) #
(Free i, Reify i a) => Reify (Abs i) (Name, a) # |
Methods reify :: Abs i -> TCM (Name, a) # reifyWhen :: Bool -> Abs i -> TCM (Name, a) #
AddContext ([WithHiding Name], Dom Type) # |
Methods addContext :: MonadTCM tcm => ([WithHiding Name], Dom Type) -> tcm a -> tcm a # contextSize :: ([WithHiding Name], Dom Type) -> Nat #
AddContext ([Name], Dom Type) # |
Methods addContext :: MonadTCM tcm => ([Name], Dom Type) -> tcm a -> tcm a # contextSize :: ([Name], Dom Type) -> Nat #
AddContext (Name, Dom Type) # |
Methods addContext :: MonadTCM tcm => (Name, Dom Type) -> tcm a -> tcm a # contextSize :: (Name, Dom Type) -> Nat #
ToAbstract r Expr => ToAbstract (Dom r, Name) TypedBindings # |
Methods toAbstract :: (Dom r, Name) -> WithNames TypedBindings #

data QName #

Qualified names are non-empty lists of names. Equality on qualified names are just equality on the last name, i.e. the module part is just for show.

The `SetRange` instance for qualified names sets all individual ranges (including those of the module prefix) to the given one.

Constructors

QName |
Fields qnameModule :: ModuleName qnameName :: Name

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 # | Only use this `show` function in debugging! To convert an abstract `QName` into a string use `prettyShow`.
Methods showsPrec :: Int -> QName -> ShowS # show :: QName -> String # showList :: [QName] -> ShowS #
NFData QName # |
Methods rnf :: QName -> () #
Hashable QName # |
Methods hashWithSalt :: Int -> QName -> Int # hash :: QName -> Int #
Pretty QName # |
Methods pretty :: QName -> Doc # prettyPrec :: Int -> QName -> Doc #
Sized QName # |
Methods size :: Integral n => QName -> n #
KillRange QName # |
Methods killRange :: KillRangeT QName #
KillRange RewriteRuleMap # |
Methods killRange :: KillRangeT RewriteRuleMap #
KillRange Definitions # |
Methods killRange :: KillRangeT Definitions #
SetRange QName # |
Methods setRange :: Range -> QName -> QName #
HasRange QName # |
Methods getRange :: QName -> Range #
NumHoles QName # |
Methods numHoles :: QName -> Int #
AllNames QName # |
Methods allNames :: QName -> Seq QName #
ExprLike QName # |
Methods recurseExpr :: Applicative m => (Expr -> m Expr -> m Expr) -> QName -> m QName # foldExpr :: Monoid m => (Expr -> m) -> QName -> m # traverseExpr :: Monad m => (Expr -> m Expr) -> QName -> m QName # mapExpr :: (Expr -> Expr) -> QName -> QName #
TermLike QName # |
Methods traverseTerm :: (Term -> Term) -> QName -> QName # traverseTermM :: Monad m => (Term -> m Term) -> QName -> m QName # foldTerm :: Monoid m => (Term -> m) -> QName -> m #
NamesIn QName # |
Methods namesIn :: QName -> Set QName #
PrettyTCM QName # |
Methods prettyTCM :: QName -> TCM Doc #
InstantiateFull QName # |
Methods instantiateFull' :: QName -> ReduceM QName #
Occurs QName # |
Methods occurs :: UnfoldStrategy -> OccursCtx -> MetaId -> Vars -> QName -> TCM QName # metaOccurs :: MetaId -> QName -> TCM () #
FromTerm QName # |
Methods fromTerm :: TCM (FromTermFunction QName) #
ToTerm QName # |
Methods toTerm :: TCM (QName -> Term) # toTermR :: TCM (QName -> ReduceM Term) #
PrimTerm QName # |
Methods primTerm :: QName -> TCM Term #
Unquote QName # |
Methods unquote :: Term -> UnquoteM QName #
UniverseBi Declaration QName # |
Methods universeBi :: Declaration -> [QName] #
ToConcrete QName QName # |
Methods toConcrete :: QName -> AbsToCon QName # bindToConcrete :: QName -> (QName -> AbsToCon b) -> AbsToCon b #
(Show a, ToQName a) => ToAbstract (OldName a) QName # |
Methods toAbstract :: OldName a -> ScopeM QName #
ToConcrete (Maybe QName) (Maybe Name) # |
Methods toConcrete :: Maybe QName -> AbsToCon (Maybe Name) # bindToConcrete :: Maybe QName -> (Maybe Name -> AbsToCon b) -> AbsToCon b #

data QNamed a #

Something preceeded by a qualified name.

Constructors

QNamed |
Fields qname :: QName qnamed :: a

Instances

Functor QNamed # |
Methods fmap :: (a -> b) -> QNamed a -> QNamed b # (<$) :: a -> QNamed b -> QNamed a #
Foldable QNamed # |
Methods fold :: Monoid m => QNamed m -> m # foldMap :: Monoid m => (a -> m) -> QNamed a -> m # foldr :: (a -> b -> b) -> b -> QNamed a -> b # foldr' :: (a -> b -> b) -> b -> QNamed a -> b # foldl :: (b -> a -> b) -> b -> QNamed a -> b # foldl' :: (b -> a -> b) -> b -> QNamed a -> b # foldr1 :: (a -> a -> a) -> QNamed a -> a # foldl1 :: (a -> a -> a) -> QNamed a -> a # toList :: QNamed a -> [a] # null :: QNamed a -> Bool # length :: QNamed a -> Int # elem :: Eq a => a -> QNamed a -> Bool # maximum :: Ord a => QNamed a -> a # minimum :: Ord a => QNamed a -> a # sum :: Num a => QNamed a -> a # product :: Num a => QNamed a -> a #
Traversable QNamed # |
Methods traverse :: Applicative f => (a -> f b) -> QNamed a -> f (QNamed b) # sequenceA :: Applicative f => QNamed (f a) -> f (QNamed a) # mapM :: Monad m => (a -> m b) -> QNamed a -> m (QNamed b) # sequence :: Monad m => QNamed (m a) -> m (QNamed a) #
Show a => Show (QNamed a) # |
Methods showsPrec :: Int -> QNamed a -> ShowS # show :: QNamed a -> String # showList :: [QNamed a] -> ShowS #
Pretty a => Pretty (QNamed a) # |
Methods pretty :: QNamed a -> Doc # prettyPrec :: Int -> QNamed a -> Doc #
PrettyTCM (QNamed Clause) # |
Methods prettyTCM :: QNamed Clause -> TCM Doc #
ToAbstract (QNamed Clause) Clause # |
Methods toAbstract :: QNamed Clause -> WithNames Clause #
Reify (QNamed Clause) Clause # |
Methods reify :: QNamed Clause -> TCM Clause # reifyWhen :: Bool -> QNamed Clause -> TCM Clause #
ToAbstract [QNamed Clause] [Clause] # |
Methods toAbstract :: [QNamed Clause] -> WithNames [Clause] #

newtype ModuleName #

A module name is just a qualified name.

The `SetRange` instance for module names sets all individual ranges to the given one.

Constructors

MName |
Fields mnameToList :: [Name]

Instances

Eq ModuleName # |
Methods (==) :: ModuleName -> ModuleName -> Bool # (/=) :: ModuleName -> ModuleName -> Bool #
Ord ModuleName # |
Methods compare :: ModuleName -> ModuleName -> Ordering # (<) :: ModuleName -> ModuleName -> Bool # (<=) :: ModuleName -> ModuleName -> Bool # (>) :: ModuleName -> ModuleName -> Bool # (>=) :: ModuleName -> ModuleName -> Bool # max :: ModuleName -> ModuleName -> ModuleName # min :: ModuleName -> ModuleName -> ModuleName #
Show ModuleName # | Only use this `show` function in debugging! To convert an abstract `ModuleName` into a string use `prettyShow`.
Methods showsPrec :: Int -> ModuleName -> ShowS # show :: ModuleName -> String # showList :: [ModuleName] -> ShowS #
NFData ModuleName # |
Methods rnf :: ModuleName -> () #
Pretty ModuleName # |
Methods pretty :: ModuleName -> Doc # prettyPrec :: Int -> ModuleName -> Doc #
Sized ModuleName # |
Methods size :: Integral n => ModuleName -> n #
KillRange ModuleName # |
Methods killRange :: KillRangeT ModuleName #
KillRange Sections # |
Methods killRange :: KillRangeT Sections #
SetRange ModuleName # |
Methods setRange :: Range -> ModuleName -> ModuleName #
HasRange ModuleName # |
Methods getRange :: ModuleName -> Range #
SubstExpr ModuleName # |
Methods substExpr :: [(Name, Expr)] -> ModuleName -> ModuleName #
ExprLike ModuleName # |
Methods recurseExpr :: Applicative m => (Expr -> m Expr -> m Expr) -> ModuleName -> m ModuleName # foldExpr :: Monoid m => (Expr -> m) -> ModuleName -> m # traverseExpr :: Monad m => (Expr -> m Expr) -> ModuleName -> m ModuleName # mapExpr :: (Expr -> Expr) -> ModuleName -> ModuleName #
PrettyTCM ModuleName # |
Methods prettyTCM :: ModuleName -> TCM Doc #
InstantiateFull ModuleName # |
Methods instantiateFull' :: ModuleName -> ReduceM ModuleName #
UniverseBi Declaration ModuleName # |
Methods universeBi :: Declaration -> [ModuleName] #
ToConcrete ModuleName QName # |
Methods toConcrete :: ModuleName -> AbsToCon QName # bindToConcrete :: ModuleName -> (QName -> AbsToCon b) -> AbsToCon b #
ToAbstract OldModuleName ModuleName # |
Methods toAbstract :: OldModuleName -> ScopeM ModuleName #
ToAbstract NewModuleQName ModuleName # |
Methods toAbstract :: NewModuleQName -> ScopeM ModuleName #
ToAbstract NewModuleName ModuleName # |
Methods toAbstract :: NewModuleName -> ScopeM ModuleName #
ToAbstract ModuleAssignment (ModuleName, [LetBinding]) # |
Methods toAbstract :: ModuleAssignment -> ScopeM (ModuleName, [LetBinding]) #

newtype AmbiguousQName #

Ambiguous qualified names. Used for overloaded constructors.

Invariant: All the names in the list must have the same concrete, unqualified name. (This implies that they all have the same `Range`).

Constructors

AmbQ |
Fields unAmbQ :: [QName]

Instances

Eq AmbiguousQName # |
Methods (==) :: AmbiguousQName -> AmbiguousQName -> Bool # (/=) :: AmbiguousQName -> AmbiguousQName -> Bool #
Ord AmbiguousQName # |
Methods compare :: AmbiguousQName -> AmbiguousQName -> Ordering # (<) :: AmbiguousQName -> AmbiguousQName -> Bool # (<=) :: AmbiguousQName -> AmbiguousQName -> Bool # (>) :: AmbiguousQName -> AmbiguousQName -> Bool # (>=) :: AmbiguousQName -> AmbiguousQName -> Bool # max :: AmbiguousQName -> AmbiguousQName -> AmbiguousQName # min :: AmbiguousQName -> AmbiguousQName -> AmbiguousQName #
Show AmbiguousQName # |
Methods showsPrec :: Int -> AmbiguousQName -> ShowS # show :: AmbiguousQName -> String # showList :: [AmbiguousQName] -> ShowS #
Pretty AmbiguousQName # |
Methods pretty :: AmbiguousQName -> Doc # prettyPrec :: Int -> AmbiguousQName -> Doc #
KillRange AmbiguousQName # |
Methods killRange :: KillRangeT AmbiguousQName #
HasRange AmbiguousQName # | The range of an `AmbiguousQName` is the range of any of its disambiguations (they are the same concrete name).
Methods getRange :: AmbiguousQName -> Range #
NumHoles AmbiguousQName # | We can have an instance for ambiguous names as all share a common concrete name.
Methods numHoles :: AmbiguousQName -> Int #
NamesIn AmbiguousQName # |
Methods namesIn :: AmbiguousQName -> Set QName #
UniverseBi Declaration AmbiguousQName # |
Methods universeBi :: Declaration -> [AmbiguousQName] #

class IsProjP a where #

Check whether we are a projection pattern.

Minimal complete definition

isProjP

Methods

isProjP :: a -> Maybe (ProjOrigin, AmbiguousQName) #

Instances

IsProjP Expr # |
Methods isProjP :: Expr -> Maybe (ProjOrigin, AmbiguousQName) #
IsProjP a => IsProjP (Arg a) # |
Methods isProjP :: Arg a -> Maybe (ProjOrigin, AmbiguousQName) #
IsProjP (Pattern' a) # |
Methods isProjP :: Pattern' a -> Maybe (ProjOrigin, AmbiguousQName) #
IsProjP (Pattern' e) # |
Methods isProjP :: Pattern' e -> Maybe (ProjOrigin, AmbiguousQName) #
IsProjP (DeBruijnPat' a) # |
Methods isProjP :: DeBruijnPat' a -> Maybe (ProjOrigin, AmbiguousQName) #
IsProjP a => IsProjP (Named n a) # |
Methods isProjP :: Named n a -> Maybe (ProjOrigin, AmbiguousQName) #

isAnonymousModuleName :: ModuleName -> Bool #

A module is anonymous if the qualification path ends in an underscore.

withRangesOf :: ModuleName -> [Name] -> ModuleName #

Sets the ranges of the individual names in the module name to match those of the corresponding concrete names. If the concrete names are fewer than the number of module name name parts, then the initial name parts get the range `noRange`.

`C.D.E `withRangesOf` [A, B]` returns `C.D.E` but with ranges set as follows:

- `C`: `noRange`.
- `D`: the range of `A`.
- `E`: the range of `B`.

Precondition: The number of module name name parts has to be at least as large as the length of the list.

withRangesOfQ :: ModuleName -> QName -> ModuleName #

Like `withRangesOf`, but uses the name parts (qualifier + name) of the qualified name as the list of concrete names.

mnameFromList :: [Name] -> ModuleName #

noModuleName :: ModuleName #

commonParentModule :: ModuleName -> ModuleName -> ModuleName #

class MkName a where #

Make a `Name` from some kind of string.

Minimal complete definition

mkName

Methods

mkName :: Range -> NameId -> a -> Name #

The `Range` sets the definition site of the name, not the use site.

mkName_ :: NameId -> a -> Name #

Instances

MkName String # |
Methods mkName :: Range -> NameId -> String -> Name # mkName_ :: NameId -> String -> Name #

qnameToList :: QName -> [Name] #

qnameFromList :: [Name] -> QName #

qnameToMName :: QName -> ModuleName #

mnameToQName :: ModuleName -> QName #

showQNameId :: QName -> String #

qnameToConcrete :: QName -> QName #

Turn a qualified name into a concrete name. This should only be used as a fallback when looking up the right concrete name in the scope fails.

mnameToConcrete :: ModuleName -> QName #

toTopLevelModuleName :: ModuleName -> TopLevelModuleName #

Computes the `TopLevelModuleName` corresponding to the given module name, which is assumed to represent a top-level module name.

Precondition: The module name must be well-formed.

qualifyM :: ModuleName -> ModuleName -> ModuleName #

qualifyQ :: ModuleName -> QName -> QName #

qualify :: ModuleName -> Name -> QName #

qualify_ :: Name -> QName #

Convert a `Name` to a `QName` (add no module name).

isOperator :: QName -> Bool #

Is the name an operator?

isSubModuleOf :: ModuleName -> ModuleName -> Bool #

isInModule :: QName -> ModuleName -> Bool #

nextName :: Name -> Name #

Get the next version of the concrete name. For instance, `nextName "x" = "x₁"`. The name must not be a `NoName`.

# Important instances: Eq, Ord, Hashable

# IsNoName instances (checking for "_")

# Show instances

# Pretty instances

# Range instances

## HasRange

## SetRange

## KillRange

# Sized instances

# NFData instances

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 #