-
Notifications
You must be signed in to change notification settings - Fork 38
Unify patterns in UCS and UPS #336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: hkmc2
Are you sure you want to change the base?
Conversation
# Conflicts: # hkmc2/shared/src/main/scala/hkmc2/codegen/Block.scala # hkmc2/shared/src/main/scala/hkmc2/codegen/Lowering.scala # hkmc2/shared/src/main/scala/hkmc2/codegen/js/JSBuilder.scala # hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala # hkmc2/shared/src/main/scala/hkmc2/semantics/Resolver.scala # hkmc2/shared/src/main/scala/hkmc2/semantics/Term.scala # hkmc2/shared/src/main/scala/hkmc2/semantics/ups/NaiveCompiler.scala # hkmc2/shared/src/test/mlscript-compile/Runtime.mjs # hkmc2/shared/src/test/mlscript/backlog/ToTriage.mls # hkmc2/shared/src/test/mlscript/codegen/ClassMatching.mls # hkmc2/shared/src/test/mlscript/codegen/MergeMatchArms.mls # hkmc2/shared/src/test/mlscript/handlers/NonLocalReturns.mls # hkmc2/shared/src/test/mlscript/handlers/RecursiveHandlers.mls # hkmc2/shared/src/test/mlscript/ucs/general/LogicalConnectives.mls # hkmc2/shared/src/test/mlscript/ups/examples/Record.mls
hkmc2/shared/src/test/mlscript/ups/specialization/SimpleLiterals.mls
Outdated
Show resolved
Hide resolved
# Conflicts: # hkmc2/shared/src/main/scala/hkmc2/codegen/Block.scala # hkmc2/shared/src/main/scala/hkmc2/semantics/Term.scala # hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/Desugarer.scala # hkmc2/shared/src/main/scala/hkmc2/syntax/Tree.scala # hkmc2/shared/src/test/mlscript/backlog/UCS.mls # hkmc2/shared/src/test/mlscript/codegen/Do.mls # hkmc2/shared/src/test/mlscript/codegen/FieldSymbols.mls # hkmc2/shared/src/test/mlscript/syntax/WeirdBrackets.mls # hkmc2/shared/src/test/mlscript/ucs/hygiene/HygienicBindings.mls # hkmc2/shared/src/test/mlscript/ucs/hygiene/PatVars.mls # hkmc2/shared/src/test/mlscript/ucs/patterns/AliasPattern.mls # hkmc2/shared/src/test/mlscript/ucs/syntax/NestedOpSplits.mls # hkmc2/shared/src/test/mlscript/ups/Future.mls # hkmc2/shared/src/test/mlscript/ups/examples/Record.mls # hkmc2/shared/src/test/mlscript/ups/parametric/EtaConversion.mls
or maybe we don't need it at all?
|
||
def duplicate: Split = | ||
val copy = this match | ||
(this match |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not keeo the val
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def duplicate: Split =
(this match
case Cons(head, tail) => Cons(head, tail.duplicate)
case Let(name, term, tail) => Let(name, term, tail.duplicate)
case Else(default) => Else(default)
case End => End).setDuplicated
It's the return value.
:e | ||
fun trimStart(str) = | ||
if str is (@compile ((" " | "\t") ~ rest)) then trimStart(rest) else str | ||
//│ ╔══[ERROR] Unrecognized pattern (unit). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this unit from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is because the pattern was parsed as part of the annotation, and nothing followed it until the closing parenthesis. As a result, the annotation was not applied to anything. Therefore, the parenthesis is treated as an empty one, which means it becomes unit.
:pe | ||
:e | ||
:w | ||
// Note: `compile ((" " | "\t") ~ rest)` is parsed as an annotation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the then
parsed as part of the annotation? 🤯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if str is @compile ((" " | "\t") ~ rest) then trimStart(rest) else str
The pattern is parsed as part of the annotation. The parser wants to parse a term next, but found then
.
# Conflicts: # hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala # hkmc2/shared/src/test/mlscript-compile/Predef.mjs # hkmc2/shared/src/test/mlscript-compile/Runtime.mjs # hkmc2/shared/src/test/mlscript/basics/LazySpreads.mls # hkmc2/shared/src/test/mlscript/codegen/ClassMatching.mls # hkmc2/shared/src/test/mlscript/ucs/patterns/RestTuple.mls
I just finished the final major refactor of this PR. The latest commit successfully declutters the For historical reasons, Now, we check the number of arguments in the pattern and call efficient pattern compilation in the process of expanding splits with nested patterns into splits with flattened patterns (handled by Later today I will do the final minor wrap-up for this PR. |
# Conflicts: # hkmc2/shared/src/main/scala/hkmc2/codegen/BlockTransformer.scala
No description provided.