Do not extend NamedVar with Kind.Identifier in DPIA#190
Merged
Conversation
Contributor
Author
|
@Bastacyclop @michel-steuwer This PR:
|
Bastacyclop
approved these changes
Jun 21, 2021
Comment on lines
-135
to
-163
| def renaming[X <: PhraseType](p: Phrase[X]): Phrase[X] = { | ||
| case class Renaming(idMap: Map[String, String]) extends VisitAndRebuild.Visitor { | ||
| override def phrase[T <: PhraseType](p: Phrase[T]): Result[Phrase[T]] = p match { | ||
| case Identifier(name, t) => Stop( | ||
| Identifier(idMap.getOrElse(name, name), | ||
| VisitAndRebuild.visitPhraseTypeAndRebuild(t, this)).asInstanceOf[Phrase[T]]) | ||
| case l @ Lambda(x, _) => | ||
| val newMap = idMap + (x.name -> freshName(x.name.takeWhile(_.isLetter))) | ||
| Continue(l, Renaming(newMap)) | ||
| case dl @ DepLambda(_, x, _) => | ||
| val newMap = idMap + (x.name -> freshName(x.name.takeWhile(_.isLetter))) | ||
| Continue(dl, Renaming(newMap)) | ||
| case _ => Continue(p, this) | ||
| } | ||
|
|
||
| override def nat[N <: Nat](n: N): N = n.visitAndRebuild({ | ||
| case i: NatIdentifier => | ||
| NatIdentifier(idMap.getOrElse(i.name, i.name)) | ||
| case ae => ae | ||
| }).asInstanceOf[N] | ||
|
|
||
| override def data[T <: DataType](dt: T): T = (dt match { | ||
| case i: DataTypeIdentifier => | ||
| DataTypeIdentifier(idMap.getOrElse(i.name, i.name)) | ||
| case dt => dt | ||
| }).asInstanceOf[T] | ||
| } | ||
| VisitAndRebuild(p, Renaming(Map())) | ||
| } |
Member
There was a problem hiding this comment.
I think that if we don't try to enforce unique names anymore, we should use proper capture-avoiding substitution here?
Member
There was a problem hiding this comment.
@Bastacyclop can you create an issue for that, please?
Comment on lines
-82
to
+86
| case pf@ParForNat(level, dim, _, name) if (eliminateVars(pf.body.asInstanceOf[DepLambda[_, _ <: Kind.Identifier, _]].x.name)) => | ||
| case pf@ParForNat(level, dim, _, name) if (eliminateVars(Kind.idName( | ||
| pf.body.asInstanceOf[DepLambda[_, _, _ <: Kind.Identifier, _]].kind, | ||
| pf.body.asInstanceOf[DepLambda[_, _, _ <: Kind.Identifier, _]].x))) => |
Member
There was a problem hiding this comment.
Maybe there is a better way to write this to avoid triple casting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This way
NamedVars are uniform across RISE, DPIA, and arithexpr. This accomplishes two things:DPIA -> arithexpr -> DPIAtranslations irrelevant.