MakeName ⇒ MkName for consistency
This commit is contained in:
parent
11b0ab6a25
commit
fca75377a0
7 changed files with 28 additions and 28 deletions
|
@ -43,14 +43,14 @@ Mods = SnocList String
|
|||
|
||||
public export
|
||||
record Name where
|
||||
constructor MakeName
|
||||
constructor MkName
|
||||
mods : Mods
|
||||
base : BaseName
|
||||
%runElab derive "Name" [Eq, Ord]
|
||||
|
||||
public export %inline
|
||||
unq : BaseName -> Name
|
||||
unq = MakeName [<]
|
||||
unq = MkName [<]
|
||||
|
||||
||| add some namespaces to the beginning of a name
|
||||
public export %inline
|
||||
|
@ -64,31 +64,31 @@ PBaseName = String
|
|||
|
||||
public export
|
||||
record PName where
|
||||
constructor MakePName
|
||||
constructor MkPName
|
||||
mods : Mods
|
||||
base : PBaseName
|
||||
%runElab derive "PName" [Eq, Ord, PrettyVal]
|
||||
|
||||
export %inline
|
||||
fromPName : PName -> Name
|
||||
fromPName p = MakeName p.mods $ UN p.base
|
||||
fromPName p = MkName p.mods $ UN p.base
|
||||
|
||||
export %inline
|
||||
toPName : Name -> PName
|
||||
toPName p = MakePName p.mods $ baseStr p.base
|
||||
toPName p = MkPName p.mods $ baseStr p.base
|
||||
|
||||
export %inline
|
||||
fromPBaseName : PBaseName -> Name
|
||||
fromPBaseName = MakeName [<] . UN
|
||||
fromPBaseName = MkName [<] . UN
|
||||
|
||||
export
|
||||
Show PName where
|
||||
show (MakePName mods base) =
|
||||
show (MkPName mods base) =
|
||||
show $ concat $ intersperse "." $ toList $ mods :< base
|
||||
|
||||
export Show Name where show = show . toPName
|
||||
|
||||
export FromString PName where fromString = MakePName [<]
|
||||
export FromString PName where fromString = MkPName [<]
|
||||
|
||||
export FromString Name where fromString = fromPBaseName
|
||||
|
||||
|
@ -116,7 +116,7 @@ export
|
|||
fromListP : List1 String -> PName
|
||||
fromListP (x ::: xs) = go [<] x xs where
|
||||
go : SnocList String -> String -> List String -> PName
|
||||
go mods x [] = MakePName mods x
|
||||
go mods x [] = MkPName mods x
|
||||
go mods x (y :: ys) = go (mods :< x) y ys
|
||||
|
||||
export %inline
|
||||
|
|
|
@ -75,7 +75,7 @@ parameters {auto _ : Functor m} (b : Var n -> m a) (f : PName -> m a)
|
|||
(xs : Context' PatVar n)
|
||||
private
|
||||
fromBaseName : PBaseName -> m a
|
||||
fromBaseName x = maybe (f $ MakePName [<] x) b $
|
||||
fromBaseName x = maybe (f $ MkPName [<] x) b $
|
||||
Context.find (\y => y.name == Just x) xs
|
||||
|
||||
private
|
||||
|
|
|
@ -124,7 +124,7 @@ qname = terminalMatch "name" `(Name n) `(n)
|
|||
||| unqualified name
|
||||
export
|
||||
baseName : Grammar True PBaseName
|
||||
baseName = terminalMatch "unqualified name" `(Name (MakePName [<] b)) `(b)
|
||||
baseName = terminalMatch "unqualified name" `(Name (MkPName [<] b)) `(b)
|
||||
|
||||
||| dimension constant (0 or 1)
|
||||
export
|
||||
|
@ -152,8 +152,8 @@ qty fname = withLoc fname [|PQ qtyVal|]
|
|||
export
|
||||
exactName : String -> Grammar True ()
|
||||
exactName name = terminal "expected '\{name}'" $ \case
|
||||
Name (MakePName [<] x) => guard $ x == name
|
||||
_ => Nothing
|
||||
Name (MkPName [<] x) => guard $ x == name
|
||||
_ => Nothing
|
||||
|
||||
|
||||
||| pattern var (unqualified name or _)
|
||||
|
|
|
@ -113,13 +113,13 @@ makeIdBase mods str = joinBy "." $ toList $ mods :< str
|
|||
|
||||
export
|
||||
makeId : Name -> Id
|
||||
makeId (MakeName mods (UN str)) = I (makeIdBase mods str) 0
|
||||
makeId (MakeName mods (MN str k)) = I (makeIdBase mods str) 0
|
||||
makeId (MakeName mods Unused) = I (makeIdBase mods "_") 0
|
||||
makeId (MkName mods (UN str)) = I (makeIdBase mods str) 0
|
||||
makeId (MkName mods (MN str k)) = I (makeIdBase mods str) 0
|
||||
makeId (MkName mods Unused) = I (makeIdBase mods "_") 0
|
||||
|
||||
export
|
||||
makeIdB : BindName -> Id
|
||||
makeIdB (BN name _) = makeId $ MakeName [<] name
|
||||
makeIdB (BN name _) = makeId $ MkName [<] name
|
||||
|
||||
private
|
||||
bump : Id -> Id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue