Safe Haskell | None |
---|
Names in the concrete syntax are just strings (or lists of strings for qualified names).
- data Name
- data NamePart
- data QName
- newtype TopLevelModuleName = TopLevelModuleName {
- moduleNameParts :: [String]
- nameToRawName :: Name -> RawName
- nameParts :: Name -> [NamePart]
- nameStringParts :: Name -> [RawName]
- stringNameParts :: String -> [NamePart]
- isOperator :: Name -> Bool
- isHole :: NamePart -> Bool
- isPrefix :: Name -> Bool
- isNonfix :: Name -> Bool
- isInfix :: Name -> Bool
- isPostfix :: Name -> Bool
- qualify :: QName -> Name -> QName
- unqualify :: QName -> Name
- qnameParts :: QName -> [Name]
- toTopLevelModuleName :: QName -> TopLevelModuleName
- moduleNameToFileName :: TopLevelModuleName -> String -> FilePath
- projectRoot :: AbsolutePath -> TopLevelModuleName -> AbsolutePath
- noName_ :: Name
- noName :: Range -> Name
- class IsNoName a where
- isNoName :: a -> Bool
Documentation
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.
Eq Name | Define equality on 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 |
Ord Name | |
Show Name | |
Typeable Name | |
NFData Name | |
Pretty Name | |
KillRange Name | |
SetRange Name | |
HasRange Name | |
Underscore Name | |
IsNoName Name | |
ExprLike Name | |
PrettyTCM Name | |
EmbPrj Name | |
ToConcrete Name Name | |
Pretty (ThingWithFixity Name) | |
ToAbstract (NewName Name) Name | |
ToConcrete (Maybe QName) (Maybe Name) |
Mixfix identifiers are composed of words and holes,
e.g. _+_
or if_then_else_
or [_/_]
.
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).
newtype TopLevelModuleName Source
Top-level module names. Used in connection with the file system.
Invariant: The list must not be empty.
TopLevelModuleName | |
|
Operations on Name
and NamePart
nameToRawName :: Name -> RawNameSource
nameStringParts :: Name -> [RawName]Source
stringNameParts :: String -> [NamePart]Source
Parse a string to parts of a concrete name.
isOperator :: Name -> BoolSource
Is the name an operator?
Operations on qualified names
qnameParts :: QName -> [Name]Source
qnameParts A.B.x = [A, B, x]
Operations on TopLevelModuleName
toTopLevelModuleName :: QName -> TopLevelModuleNameSource
Turns a qualified name into a TopLevelModuleName
. The qualified
name is assumed to represent a top-level module name.
moduleNameToFileName :: TopLevelModuleName -> String -> FilePathSource
Turns a top-level module name into a file name with the given suffix.
projectRoot :: AbsolutePath -> TopLevelModuleName -> AbsolutePathSource
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
Check whether a name is the empty name _.