diff --git a/hkmc2/jvm/src/test/scala/hkmc2/MLsDiffMaker.scala b/hkmc2/jvm/src/test/scala/hkmc2/MLsDiffMaker.scala index 21db964e6..9b9a87349 100644 --- a/hkmc2/jvm/src/test/scala/hkmc2/MLsDiffMaker.scala +++ b/hkmc2/jvm/src/test/scala/hkmc2/MLsDiffMaker.scala @@ -51,14 +51,11 @@ abstract class MLsDiffMaker extends DiffMaker: val showUCS = Command("ucs"): ln => ln.split(" ").iterator.map(x => "ucs:" + x.trim).toSet - val compilePatterns = NullaryCommand("cp") - given Elaborator.State = new Elaborator.State: override def dbg: Bool = dbgParsing.isSet || dbgElab.isSet || debug.isSet - override def shouldCompilePatterns: Bool = compilePatterns.isSet val etl = new TraceLogger: override def doTrace = dbgElab.isSet || scope.exists: diff --git a/hkmc2/shared/src/main/scala/hkmc2/semantics/Desugarer.scala b/hkmc2/shared/src/main/scala/hkmc2/semantics/Desugarer.scala index 188266d0a..ce9369e9a 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/semantics/Desugarer.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/semantics/Desugarer.scala @@ -9,7 +9,7 @@ import hkmc2.syntax.Literal import Keyword.{as, and, `do`, `else`, is, let, `then`} import collection.mutable.{HashMap, SortedSet} import Elaborator.{ctx, Ctxl} -import ucs.DesugaringBase +import ucs.{DesugaringBase, warn, error} object Desugarer: extension (op: Keyword.Infix) @@ -66,6 +66,8 @@ class Desugarer(val elaborator: Elaborator) // represents the context with bindings in the current match. type Sequel = Ctx => Split + + type Ctor = SynthSel | Sel | Ident extension (sequel: Sequel) def traced(pre: Str, post: Split => Str): Sequel = @@ -409,6 +411,22 @@ class Desugarer(val elaborator: Elaborator) */ def expandMatch(scrutSymbol: BlockLocalSymbol, pattern: Tree, sequel: Sequel): Split => Sequel = def ref = scrutSymbol.ref(/* FIXME ident? */) + def dealWithCtorCase(ctor: Ctor, compile: Bool)(fallback: Split): Sequel = ctx => + val clsTrm = elaborator.cls(ctor, inAppPrefix = false) + clsTrm.symbol.flatMap(_.asClsLike) match + case S(cls: ClassSymbol) => + if compile then warn(msg"Cannot compile the class `${cls.name}`" -> ctor.toLoc) + Branch(ref, Pattern.ClassLike(cls, clsTrm, N, false)(ctor), sequel(ctx)) ~: fallback + case S(mod: ModuleSymbol) => + if compile then warn(msg"Cannot compile the module `${mod.name}`" -> ctor.toLoc) + Branch(ref, Pattern.ClassLike(mod, clsTrm, N, false)(ctor), sequel(ctx)) ~: fallback + case S(pat: PatternSymbol) => + if compile then Branch(ref, Pattern.Synonym(pat, N), sequel(ctx)) ~: fallback + else makeUnapplyBranch(ref, clsTrm, sequel(ctx))(fallback) + case N => + // Raise an error and discard `sequel`. Use `fallback` instead. + raise(ErrorReport(msg"Cannot use this ${ctor.describe} as a pattern" -> ctor.toLoc :: Nil)) + fallback pattern match // A single wildcard pattern. case Under() => _ => ctx => sequel(ctx) @@ -423,22 +441,11 @@ class Desugarer(val elaborator: Elaborator) val aliasSymbol = VarSymbol(id) val ctxWithAlias = ctx + (nme -> aliasSymbol) Split.Let(aliasSymbol, ref, sequel(ctxWithAlias) ++ fallback) - case ctor @ (_: Ident | _: SynthSel | _: Sel) => fallback => ctx => - val clsTrm = elaborator.cls(ctor, inAppPrefix = false) - clsTrm.symbol.flatMap(_.asClsLike) match - case S(cls: ClassSymbol) => - Branch(ref, Pattern.ClassLike(cls, clsTrm, N, false)(ctor), sequel(ctx)) ~: fallback - case S(cls: ModuleSymbol) => - Branch(ref, Pattern.ClassLike(cls, clsTrm, N, false)(ctor), sequel(ctx)) ~: fallback - case S(psym: PatternSymbol) => - if state.shouldCompilePatterns then - Branch(ref, Pattern.Synonym(psym, N), sequel(ctx)) ~: fallback - else - makeUnapplyBranch(ref, clsTrm, sequel(ctx))(fallback) - case N => - // Raise an error and discard `sequel`. Use `fallback` instead. - raise(ErrorReport(msg"Cannot use this ${ctor.describe} as a pattern" -> ctor.toLoc :: Nil)) - fallback + case ctor: Ctor => dealWithCtorCase(ctor, false) + case Annotated(Ident("compile"), ctor: Ctor) => dealWithCtorCase(ctor, true) + case Annotated(annotation, ctor: Ctor) => + error(msg"Unrecognized annotation on patterns" -> annotation.toLoc) + dealWithCtorCase(ctor, false) case Tree.Tup(args) => fallback => ctx => trace( pre = s"expandMatch <<< ${args.mkString(", ")}", post = (r: Split) => s"expandMatch >>> ${r.showDbg}" diff --git a/hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala b/hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala index abc9f0678..beeaad7dc 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala @@ -137,7 +137,6 @@ object Elaborator: )) def dbg: Bool = false def dbgUid(uid: Uid[Symbol]): Str = if dbg then s"‹$uid›" else "" - def shouldCompilePatterns: Bool = false // TODO: remove after annotations introduced transparent inline def State(using state: State): State = state end Elaborator @@ -810,13 +809,11 @@ extends Importer: val owner = ctx.outer newCtx.nest(S(patSym)).givenIn: assert(body.isEmpty) - patSym.split = if state.shouldCompilePatterns then - td.extension.map: tree => - val split = ucs.DeBrujinSplit.elaborate(tree, this) - scoped("ucs:rp:elaborated"): - log(s"elaborated nameless split:\n${split.display}") - split - else None + patSym.split = td.extension.map: tree => + val split = ucs.DeBrujinSplit.elaborate(tree, this) + scoped("ucs:rp:elaborated"): + log(s"elaborated nameless split:\n${split.display}") + split log(s"pattern body is ${td.extension}") val translate = new ucs.Translator(this) val bod = translate(ps.map(_.params).getOrElse(Nil), td.extension.getOrElse(die)) diff --git a/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/DeBrujinSplit.scala b/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/DeBrujinSplit.scala index c9c426070..83f5559d7 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/DeBrujinSplit.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/DeBrujinSplit.scala @@ -50,6 +50,16 @@ object DeBrujinSplit: Branch(_, Literal(IntLit(-n)), _, _) case App(Ident("-"), Tup(DecLit(n) :: Nil)) => Branch(_, Literal(DecLit(-n)), _, _) + // BEGIN TODO: Support range patterns. This is just to suppress the errors. + case (lo: StrLit) to (incl, hi: StrLit) => + (_, _, alternative) => alternative + case (lo: IntLit) to (incl, hi: IntLit) => + (_, _, alternative) => alternative + case (lo: DecLit) to (incl, hi: DecLit) => + (_, _, alternative) => alternative + case (lo: syntax.Literal) to (_, hi: syntax.Literal) => + (_, _, alternative) => alternative + // END TODO: Support range patterns case App(ctor: (Ident | Sel), Tup(params)) => cls(ctor, params) case literal: syntax.Literal => Branch(_, Literal(literal), _, _) scoped("ucs:rp:elaborate"): @@ -149,7 +159,6 @@ extension (branch: DeBrujinSplit.Branch) case Branch(`scrutinee`, ClassLike(symbol: PatternSymbol), consequence, alternative) => val patternSplit = symbol.split.getOrElse: lastWords(s"found unelaborated pattern: ${symbol.nme}") - // val consequence2 = consequence // TODO: why can't we expand the consequence? val consequence2 = go(consequence, scrutinee) val alternative2 = go(alternative, scrutinee) patternSplit.expand(scrutinee :: Nil, consequence2) ++ alternative2 diff --git a/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/Translator.scala b/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/Translator.scala index 9b39ef21c..422ee6832 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/Translator.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/Translator.scala @@ -8,6 +8,19 @@ import Split.display, ucs.Normalization import syntax.{Fun, Keyword, Literal, ParamBind, Tree}, Tree.*, Keyword.`as` import scala.collection.mutable.{Buffer, Set as MutSet} +object Translator: + /** String range bounds must be single characters. */ + def isInvalidStringBounds(lo: StrLit, hi: StrLit)(using Raise): Bool = + val ds = Buffer.empty[(Message, Option[Loc])] + if lo.value.length != 1 then + ds += msg"String range bounds must have only one character." -> lo.toLoc + if hi.value.length != 1 then + ds += msg"String range bounds must have only one character." -> hi.toLoc + if ds.nonEmpty then error(ds.toSeq*) + ds.nonEmpty + +import Translator.* + /** This class translates a tree describing a pattern into functions that can * perform pattern matching on terms described by the pattern. */ @@ -42,16 +55,6 @@ class Translator(val elaborator: Elaborator) val test2 = app(upperOp.ref(), tup(scrutFld, fld(Term.Lit(hi))), "ltHi") plainTest(test1, "gtLo")(plainTest(test2, "ltHi")(inner(Map.empty))) - /** String range bounds must be single characters. */ - private def isInvalidStringBounds(lo: StrLit, hi: StrLit)(using Raise): Bool = - val ds = Buffer.empty[(Message, Option[Loc])] - if lo.value.length != 1 then - ds += msg"String range bounds must have only one character." -> lo.toLoc - if hi.value.length != 1 then - ds += msg"String range bounds must have only one character." -> hi.toLoc - if ds.nonEmpty then error(ds.toSeq*) - ds.nonEmpty - /** Generate a split that consumes the entire scrutinee. */ private def full(scrut: Scrut, pat: Tree, inner: Inner)(using Raise): Split = trace( pre = s"full <<< $pat", diff --git a/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/package.scala b/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/package.scala index dfe824e6b..25bff9ae0 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/package.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/package.scala @@ -2,9 +2,9 @@ package hkmc2 package semantics package object ucs: - private[ucs] def error(msgs: (Message, Option[Loc])*)(using Raise): Unit = + def error(msgs: (Message, Option[Loc])*)(using Raise): Unit = raise(ErrorReport(msgs.toList)) - private[ucs] def warn(msgs: (Message, Option[Loc])*)(using Raise): Unit = + def warn(msgs: (Message, Option[Loc])*)(using Raise): Unit = raise(WarningReport(msgs.toList)) end ucs diff --git a/hkmc2/shared/src/test/mlscript/rp/Future.mls b/hkmc2/shared/src/test/mlscript/rp/Future.mls index 2b8bbd23a..c5c4a2adf 100644 --- a/hkmc2/shared/src/test/mlscript/rp/Future.mls +++ b/hkmc2/shared/src/test/mlscript/rp/Future.mls @@ -27,10 +27,7 @@ pattern Email(name, domain) = :todo // View patterns pattern GreaterThan(value) = case n and n > value then n -//│ ╔══[ERROR] Unrecognized pattern. -//│ ║ l.29: n and n > value then n -//│ ╙── ^^^^^^^^^^^^^^^^^^^^^^ -//│ /!!!\ Uncaught error: java.lang.AssertionError: assertion failed +//│ /!!!\ Uncaught error: scala.MatchError: Case(None,Block(List(InfixApp(InfixApp(Ident(n),keyword 'and',App(Ident(>),Tup(List(Ident(n), Ident(value))))),keyword 'then',Ident(n))))) (of class hkmc2.syntax.Tree$Case) :todo // Normal view pattern @@ -42,11 +39,11 @@ fun foo(x) = if x is Unit then .... Arrow(...) then .... //│ ╔══[ERROR] Unrecognized pattern split. -//│ ║ l.41: view as +//│ ║ l.38: view as //│ ║ ^^^^^^^ -//│ ║ l.42: Unit then .... +//│ ║ l.39: Unit then .... //│ ║ ^^^^^^^^^^^^^^^^^^ -//│ ║ l.43: Arrow(...) then .... +//│ ║ l.40: Arrow(...) then .... //│ ╙── ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -64,16 +61,14 @@ pattern Star(pattern T) = "" | Many(T) pattern Email(name, domains) = Rep(Char | ".") as name ~ "@" ~ Rep(Rep(Char) ~ ) as domain //│ ╔══[PARSE ERROR] Expected end of input; found literal instead -//│ ║ l.61: pattern Char = "a" to "z" | "A" to "Z" | "0" to "9" | "_" | "-" +//│ ║ l.58: pattern Char = "a" to "z" | "A" to "Z" | "0" to "9" | "_" | "-" //│ ╙── ^^^ -//│ ╔══[ERROR] Unrecognized pattern. -//│ ║ l.61: pattern Char = "a" to "z" | "A" to "Z" | "0" to "9" | "_" | "-" -//│ ╙── ^^^^^^ +//│ /!!!\ Uncaught error: scala.MatchError: Jux(StrLit(a),Ident(to)) (of class hkmc2.syntax.Tree$Jux) :todo pattern Test(foo, bar) = ("foo" as foo) ~ ("bar" as bar) //│ ╔══[ERROR] Unrecognized pattern. -//│ ║ l.74: pattern Test(foo, bar) = ("foo" as foo) ~ ("bar" as bar) +//│ ║ l.69: pattern Test(foo, bar) = ("foo" as foo) ~ ("bar" as bar) //│ ╙── ^^^^^^^^^^^^ //│ /!!!\ Uncaught error: java.lang.AssertionError: assertion failed @@ -96,7 +91,7 @@ pattern Lines(pattern L) = case :todo if input is Lines of Email then //│ ╔══[PARSE ERROR] Expected start of statement in this position; found end of input instead -//│ ║ l.97: if input is Lines of Email then +//│ ║ l.92: if input is Lines of Email then //│ ╙── ^ //│ /!!!\ Uncaught error: scala.MatchError: TypeDef(Pat,Ident(L),None,None) (of class hkmc2.syntax.Tree$TypeDef) @@ -112,13 +107,13 @@ pattern Email(name, domain) = ... :todo if input is Opt(Email, Some((n, d))) then ... //│ ╔══[ERROR] Name not found: input -//│ ║ l.113: if input is Opt(Email, Some((n, d))) then ... +//│ ║ l.108: if input is Opt(Email, Some((n, d))) then ... //│ ╙── ^^^^^ //│ ╔══[ERROR] Name not found: Opt -//│ ║ l.113: if input is Opt(Email, Some((n, d))) then ... +//│ ║ l.108: if input is Opt(Email, Some((n, d))) then ... //│ ╙── ^^^ //│ ╔══[ERROR] Cannot use this identifier as an extractor -//│ ║ l.113: if input is Opt(Email, Some((n, d))) then ... +//│ ║ l.108: if input is Opt(Email, Some((n, d))) then ... //│ ╙── ^^^ :todo @@ -136,8 +131,6 @@ pattern Opt(pattern P) = case :todo pattern Digits = "0" to "9" ~ (Digits | "") //│ ╔══[PARSE ERROR] Expected end of input; found literal instead -//│ ║ l.137: pattern Digits = "0" to "9" ~ (Digits | "") +//│ ║ l.132: pattern Digits = "0" to "9" ~ (Digits | "") //│ ╙── ^^^ -//│ ╔══[ERROR] Unrecognized pattern. -//│ ║ l.137: pattern Digits = "0" to "9" ~ (Digits | "") -//│ ╙── ^^^^^^ +//│ /!!!\ Uncaught error: scala.MatchError: Jux(StrLit(0),Ident(to)) (of class hkmc2.syntax.Tree$Jux) diff --git a/hkmc2/shared/src/test/mlscript/rp/RangePatterns.mls b/hkmc2/shared/src/test/mlscript/rp/RangePatterns.mls index 7480baaff..be9e26dd3 100644 --- a/hkmc2/shared/src/test/mlscript/rp/RangePatterns.mls +++ b/hkmc2/shared/src/test/mlscript/rp/RangePatterns.mls @@ -55,6 +55,9 @@ pattern UnsignedByte = 0..< 256 //│ ╔══[ERROR] Name not found: .< //│ ║ l.51: pattern UnsignedByte = 0..< 256 //│ ╙── ^^ +//│ ╔══[ERROR] Name not found: .< +//│ ║ l.51: pattern UnsignedByte = 0..< 256 +//│ ╙── ^^ //│ ╔══[ERROR] Cannot use this identifier as an extractor //│ ║ l.51: pattern UnsignedByte = 0..< 256 //│ ╙── ^^ @@ -62,7 +65,7 @@ pattern UnsignedByte = 0..< 256 :e pattern BadRange = "s"..=0 //│ ╔══[ERROR] Incompatible range types: string literal to integer literal -//│ ║ l.63: pattern BadRange = "s"..=0 +//│ ║ l.66: pattern BadRange = "s"..=0 //│ ╙── ^^^^^^^ // It becomes an absurd pattern. @@ -72,14 +75,14 @@ pattern BadRange = "s"..=0 :e pattern BadRange = 0 ..= "s" //│ ╔══[ERROR] Incompatible range types: integer literal to string literal -//│ ║ l.73: pattern BadRange = 0 ..= "s" +//│ ║ l.76: pattern BadRange = 0 ..= "s" //│ ╙── ^^^^^^^^^ :e pattern BadRange = "yolo" ..= "swag" //│ ╔══[ERROR] String range bounds must have only one character. -//│ ║ l.79: pattern BadRange = "yolo" ..= "swag" +//│ ║ l.82: pattern BadRange = "yolo" ..= "swag" //│ ║ ^^^^^^ //│ ╟── String range bounds must have only one character. -//│ ║ l.79: pattern BadRange = "yolo" ..= "swag" +//│ ║ l.82: pattern BadRange = "yolo" ..= "swag" //│ ╙── ^^^^^^ diff --git a/hkmc2/shared/src/test/mlscript/rp/examples/Identifier.mls b/hkmc2/shared/src/test/mlscript/rp/examples/Identifier.mls index 39964cde9..effa0f698 100644 --- a/hkmc2/shared/src/test/mlscript/rp/examples/Identifier.mls +++ b/hkmc2/shared/src/test/mlscript/rp/examples/Identifier.mls @@ -28,6 +28,9 @@ pattern Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" :ucs rp:elaborated pattern Lower = "a"..="z" +//│ elaborated nameless split: +//│ > a => +//│ > reject :expect true "a" is Lower diff --git a/hkmc2/shared/src/test/mlscript/rp/nondeterminism/EvenOddTree.mls b/hkmc2/shared/src/test/mlscript/rp/nondeterminism/EvenOddTree.mls index a81b5ccea..807cd58ed 100644 --- a/hkmc2/shared/src/test/mlscript/rp/nondeterminism/EvenOddTree.mls +++ b/hkmc2/shared/src/test/mlscript/rp/nondeterminism/EvenOddTree.mls @@ -7,29 +7,11 @@ class Pair[A, B](first: A, second: B) [A, B] //│ = [ A { class: [class A] }, B { class: [class B] } ] -:cp pattern OddTree = A | Pair(EvenTree, OddTree) | Pair(OddTree, EvenTree) pattern EvenTree = B | Pair(EvenTree, EvenTree) | Pair(OddTree, OddTree) // This does not work for now. -:cp -:ucs desugared rp:normalize rp:expand rp:memo +:todo A is EvenTree -//│ Desugared: -//│ > if -//│ > let $scrut = globalThis:block#1#666(.)A‹member:A› -//│ > $scrut is EvenTree then true -//│ > else false -//│ FAILURE: Unexpected exception -//│ /!!!\ Uncaught error: java.lang.Exception: Internal Error: found unelaborated pattern: EvenTree -//│ at: mlscript.utils.package$.lastWords(package.scala:230) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.$anonfun$10(DeBrujinSplit.scala:292) -//│ at: scala.Option.getOrElse(Option.scala:201) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$12$$anonfun$1(DeBrujinSplit.scala:292) -//│ at: hkmc2.utils.TraceLogger.scoped(TraceLogger.scala:37) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$12(DeBrujinSplit.scala:350) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$12$$anonfun$1(DeBrujinSplit.scala:285) -//│ at: hkmc2.utils.TraceLogger.scoped(TraceLogger.scala:37) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$12(DeBrujinSplit.scala:350) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.normalize(DeBrujinSplit.scala:352) +//│ = false diff --git a/hkmc2/shared/src/test/mlscript/rp/recursion/BitSeq.mls b/hkmc2/shared/src/test/mlscript/rp/recursion/BitSeq.mls index 2638f7ec1..cff7df33f 100644 --- a/hkmc2/shared/src/test/mlscript/rp/recursion/BitSeq.mls +++ b/hkmc2/shared/src/test/mlscript/rp/recursion/BitSeq.mls @@ -1,32 +1,35 @@ :js -:cp class Pair[A, B](val first: A, val second: B) pattern Bit = 0 | 1 :expect true -0 is Bit +0 is @compile Bit //│ = true :expect true -1 is Bit +1 is @compile Bit //│ = true :expect false -42 is Bit +42 is @compile Bit //│ = false pattern BitSeq = null | Pair(Bit, BitSeq) -null is BitSeq +:expect true +null is @compile BitSeq //│ = true -Pair(0, null) is BitSeq +:expect true +Pair(0, null) is @compile BitSeq //│ = true -Pair(1, Pair(0, null)) is BitSeq +:expect true +Pair(1, Pair(0, null)) is @compile BitSeq //│ = true -Pair(2, null) is BitSeq +:expect false +Pair(2, null) is @compile BitSeq //│ = false diff --git a/hkmc2/shared/src/test/mlscript/rp/recursion/BitTree.mls b/hkmc2/shared/src/test/mlscript/rp/recursion/BitTree.mls index 63ad2d6ec..6b88b0901 100644 --- a/hkmc2/shared/src/test/mlscript/rp/recursion/BitTree.mls +++ b/hkmc2/shared/src/test/mlscript/rp/recursion/BitTree.mls @@ -2,34 +2,29 @@ class Pair[A, B](val first: A, val second: B) -:cp pattern Bit = 0 | 1 :expect true -0 is Bit +0 is @compile Bit //│ = true :expect true -1 is Bit +1 is @compile Bit //│ = true :expect false -42 is Bit +42 is @compile Bit //│ = false // :ucs rp:elaborated -:cp pattern BitTree = null | Pair(Bit | BitTree, Bit | BitTree) -:cp null is BitTree //│ = true -:cp Pair(null, null) is BitTree -//│ = false +//│ = true -// :ucs rp:elaborated pattern BinTree = null | Pair(BinTree | 0 | 1, BinTree | 0 | 1) :todo diff --git a/hkmc2/shared/src/test/mlscript/rp/recursion/NatBox.mls b/hkmc2/shared/src/test/mlscript/rp/recursion/NatBox.mls index f352e9e39..9f5a6766a 100644 --- a/hkmc2/shared/src/test/mlscript/rp/recursion/NatBox.mls +++ b/hkmc2/shared/src/test/mlscript/rp/recursion/NatBox.mls @@ -1,5 +1,4 @@ :js -:cp class Box[A](val value: A) @@ -7,6 +6,10 @@ pattern NatBox = null | Box(NatBox) fun nat(n) = if n is 0 then null else Box(nat(n - 1)) +fun int(n) = if n is + null then 0 + Box(x) then 1 + int(x) + [nat(0), nat(1), nat(2), nat(3)] //│ > [ //│ > null, @@ -15,71 +18,74 @@ fun nat(n) = if n is 0 then null else Box(nat(n - 1)) //│ > Box { value: Box { value: [Box] } } //│ = ] +int(nat(42)) +//│ = 42 + :expect true -nat(0) is NatBox +nat(0) is @compile NatBox //│ = true :expect true -nat(1) is NatBox +nat(1) is @compile NatBox //│ = true :expect false -Box(0) is NatBox +Box(0) is @compile NatBox //│ = false :expect true -nat(7) is NatBox +nat(7) is @compile NatBox //│ = true :expect true -nat(14) is NatBox +nat(14) is @compile NatBox //│ = true :expect false -Box(Box(Box(Box(Box(Box(Box(0))))))) is NatBox +Box(Box(Box(Box(Box(Box(Box(0))))))) is @compile NatBox //│ = false pattern PosNatBox = Box(null | NatBox) :expect false -null is PosNatBox +null is @compile PosNatBox //│ = false -nat(1) is PosNatBox +nat(1) is @compile PosNatBox //│ = true :expect true -nat(2) is PosNatBox +nat(2) is @compile PosNatBox //│ = true :expect true -nat(3) is PosNatBox +nat(3) is @compile PosNatBox //│ = true :expect false -Box(Box(Box(Box(42)))) is PosNatBox +Box(Box(Box(Box(42)))) is @compile PosNatBox //│ = false pattern EvenNatBox = Box(Box(null | EvenNatBox)) :expect false -nat(0) is EvenNatBox +nat(0) is @compile EvenNatBox //│ = false :expect false -nat(1) is EvenNatBox +nat(1) is @compile EvenNatBox //│ = false :expect true -nat(2) is EvenNatBox +nat(2) is @compile EvenNatBox //│ = true :expect false -nat(3) is EvenNatBox +nat(3) is @compile EvenNatBox //│ = false :expect true -nat(4) is EvenNatBox +nat(4) is @compile EvenNatBox //│ = true // Make the base case a new pattern. @@ -92,25 +98,25 @@ null is Zero pattern OddNatBox = Box(Zero | Box(OddNatBox)) :expect false -nat(0) is OddNatBox +nat(0) is @compile OddNatBox //│ = false :expect true -nat(1) is OddNatBox +nat(1) is @compile OddNatBox //│ = true :expect false -nat(2) is OddNatBox +nat(2) is @compile OddNatBox //│ = false :expect true -nat(3) is OddNatBox +nat(3) is @compile OddNatBox //│ = true :expect false -nat(4) is OddNatBox +nat(4) is @compile OddNatBox //│ = false :expect false -Box(Box(78)) is OddNatBox +Box(Box(78)) is @compile OddNatBox //│ = false diff --git a/hkmc2/shared/src/test/mlscript/rp/recursion/NullTree.mls b/hkmc2/shared/src/test/mlscript/rp/recursion/NullTree.mls index d2fbfe0e5..dc78c4d35 100644 --- a/hkmc2/shared/src/test/mlscript/rp/recursion/NullTree.mls +++ b/hkmc2/shared/src/test/mlscript/rp/recursion/NullTree.mls @@ -1,15 +1,12 @@ :js - class Pair[A, B](val first: A, val second: B) -:cp pattern Null = null [null is Null, 0 is Null, false is Null] //│ = [ true, false, false ] -:cp pattern Tree = Null | Pair(Tree, Tree) fun (##) concat(a, b) = Pair(a, b) @@ -23,751 +20,25 @@ fun (##) concat(a, b) = Pair(a, b) :global :expect true -:cp -:ucs rp:memo -null is Tree -//│ normalize <<< -//│ > 1 is null -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> accept 42 -//│ | normalize <<< -//│ | > 1 is class:Pair -> λ λ -//│ | > 2 is pattern:Tree -> 1 is pattern:Tree -> accept 42 -//│ | | normalize <<< -//│ | | > 2 is null -> 1 is pattern:Tree -> accept 42 -//│ | | > 2 is class:Pair -> λ λ -//│ | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ | | | normalize <<< -//│ | | | > 1 is null -> accept 42 -//│ | | | > 1 is class:Pair -> λ λ -//│ | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> accept 42 -//│ | | | | this is a recursive split -//│ | | | normalize >>> -//│ | | | > 1 is local:0 -> accept 42 -//│ | | | normalize <<< -//│ | | | > 2 is class:Pair -> λ λ -//│ | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ | | | | normalize <<< -//│ | | | | > 2 is null -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ | | | | > 2 is class:Pair -> λ λ -//│ | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> accept 42 -//│ | | | | | normalize <<< -//│ | | | | | > 1 is null -> 3 is pattern:Tree -> accept 42 -//│ | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> accept 42 -//│ | | | | | | normalize <<< -//│ | | | | | | > 3 is null -> accept 42 -//│ | | | | | | > 3 is class:Pair -> λ λ -//│ | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> accept 42 -//│ | | | | | | | normalize <<< -//│ | | | | | | | > 3 is class:Pair -> λ λ -//│ | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> accept 42 -//│ | | | | | | | normalize >>> -//│ | | | | | | | > 3 is class:Pair -> λ λ -//│ | | | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> accept 42 -//│ | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ | | | | | | normalize >>> -//│ | | | | | | > 3 is null -> accept 42 -//│ | | | | | | > 3 is class:Pair -> λ λ -//│ | | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> accept 42 -//│ | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ | | | | | | normalize <<< -//│ | | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> accept 42 -//│ | | | | | | | normalize <<< -//│ | | | | | | | > 2 is null -> 1 is pattern:Tree -> 5 is pattern:Tree -> accept 42 -//│ | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | | | normalize <<< -//│ | | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | | | normalize >>> -//│ | | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | | | normalize >>> -//│ | | | | | | | > 2 is null -> -//│ | | | | | | | > 1 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ | | | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | | normalize >>> -//│ | | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | | > 2 is null -> -//│ | | | | | | > 1 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ | | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | normalize >>> -//│ | | | | | > 1 is null -> -//│ | | | | | > 3 is null -> accept 42 -//│ | | | | | > 3 is class:Pair -> λ λ -//│ | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> accept 42 -//│ | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | > 2 is null -> -//│ | | | | | > 1 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | normalize <<< -//│ | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> accept 42 -//│ | | | | | | normalize <<< -//│ | | | | | | > 2 is null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> accept 42 -//│ | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | | normalize <<< -//│ | | | | | | | > 1 is null -> 3 is pattern:Tree -> 5 is pattern:Tree -> accept 42 -//│ | | | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | | | normalize <<< -//│ | | | | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | | | normalize >>> -//│ | | | | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | | | normalize >>> -//│ | | | | | | | > 1 is null -> -//│ | | | | | | | > 3 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ | | | | | | | > 3 is class:Pair -> λ λ -//│ | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | | | normalize <<< -//│ | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | | | normalize <<< -//│ | | | | | | | | > 2 is null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | | | | | normalize <<< -//│ | | | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | | | | | normalize >>> -//│ | | | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ | | | | | | | | normalize >>> -//│ | | | | | | | | > 2 is null -> -//│ | | | | | | | | > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ | | | | | | | normalize >>> -//│ | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | > 2 is null -> -//│ | | | | | | | > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ | | | | | | normalize >>> -//│ | | | | | | > 2 is null -> -//│ | | | | | | > 1 is null -> -//│ | | | | | | > 3 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ | | | | | | > 3 is class:Pair -> λ λ -//│ | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | > 2 is null -> -//│ | | | | | | > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ | | | | | normalize >>> -//│ | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | > 2 is null -> -//│ | | | | | > 1 is null -> -//│ | | | | | > 3 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ | | | | | > 3 is class:Pair -> λ λ -//│ | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | > 2 is null -> -//│ | | | | | > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | | > 1 is class:Pair -> λ λ -//│ | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | | > 2 is class:Pair -> λ λ -//│ | | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ | | | | normalize >>> -//│ | | | | > 2 is null -> -//│ | | | | > 1 is null -> -//│ | | | | > 3 is null -> accept 42 -//│ | | | | > 3 is class:Pair -> λ λ -//│ | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> accept 42 -//│ | | | | > 2 is class:Pair -> λ λ -//│ | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ | | | | > 1 is class:Pair -> λ λ -//│ | | | | > 2 is null -> -//│ | | | | > 1 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ | | | | > 1 is class:Pair -> λ λ -//│ | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | > 2 is class:Pair -> λ λ -//│ | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | > 2 is class:Pair -> λ λ -//│ | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | > 2 is class:Pair -> λ λ -//│ | | | | > 2 is null -> -//│ | | | | > 1 is null -> -//│ | | | | > 3 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ | | | | > 3 is class:Pair -> λ λ -//│ | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | > 1 is class:Pair -> λ λ -//│ | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | > 2 is class:Pair -> λ λ -//│ | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | > 2 is class:Pair -> λ λ -//│ | | | | > 2 is null -> -//│ | | | | > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | | > 1 is class:Pair -> λ λ -//│ | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | > 2 is class:Pair -> λ λ -//│ | | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | | > 2 is class:Pair -> λ λ -//│ | | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ | | | normalize >>> -//│ | | | > 2 is class:Pair -> λ λ -//│ | | | > 2 is null -> -//│ | | | > 1 is null -> -//│ | | | > 3 is null -> accept 42 -//│ | | | > 3 is class:Pair -> λ λ -//│ | | | > 2 is pattern:Null -> 1 is pattern:Tree -> accept 42 -//│ | | | > 2 is class:Pair -> λ λ -//│ | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ | | | > 1 is class:Pair -> λ λ -//│ | | | > 2 is null -> -//│ | | | > 1 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ | | | > 1 is class:Pair -> λ λ -//│ | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | > 2 is class:Pair -> λ λ -//│ | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | > 2 is class:Pair -> λ λ -//│ | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | > 2 is class:Pair -> λ λ -//│ | | | > 2 is null -> -//│ | | | > 1 is null -> -//│ | | | > 3 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ | | | > 3 is class:Pair -> λ λ -//│ | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | > 1 is class:Pair -> λ λ -//│ | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | > 2 is class:Pair -> λ λ -//│ | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | > 2 is class:Pair -> λ λ -//│ | | | > 2 is null -> -//│ | | | > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | | > 1 is class:Pair -> λ λ -//│ | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | > 2 is class:Pair -> λ λ -//│ | | | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | | > 2 is class:Pair -> λ λ -//│ | | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ | | normalize >>> -//│ | | > 2 is null -> 1 is local:0 -> accept 42 -//│ | | > 2 is class:Pair -> λ λ -//│ | | > 2 is null -> -//│ | | > 1 is null -> -//│ | | > 3 is null -> accept 42 -//│ | | > 3 is class:Pair -> λ λ -//│ | | > 2 is pattern:Null -> 1 is pattern:Tree -> accept 42 -//│ | | > 2 is class:Pair -> λ λ -//│ | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ | | > 1 is class:Pair -> λ λ -//│ | | > 2 is null -> -//│ | | > 1 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ | | > 1 is class:Pair -> λ λ -//│ | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | > 2 is class:Pair -> λ λ -//│ | | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | > 2 is class:Pair -> λ λ -//│ | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | > 2 is class:Pair -> λ λ -//│ | | > 2 is null -> -//│ | | > 1 is null -> -//│ | | > 3 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ | | > 3 is class:Pair -> λ λ -//│ | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | > 1 is class:Pair -> λ λ -//│ | | > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | > 2 is class:Pair -> λ λ -//│ | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | > 2 is class:Pair -> λ λ -//│ | | > 2 is null -> -//│ | | > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | | > 1 is class:Pair -> λ λ -//│ | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | > 2 is class:Pair -> λ λ -//│ | | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | | > 2 is class:Pair -> λ λ -//│ | | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ | normalize >>> -//│ | > 1 is class:Pair -> λ λ -//│ | > 2 is null -> 1 is local:0 -> accept 42 -//│ | > 2 is class:Pair -> λ λ -//│ | > 2 is null -> -//│ | > 1 is null -> -//│ | > 3 is null -> accept 42 -//│ | > 3 is class:Pair -> λ λ -//│ | > 2 is pattern:Null -> 1 is pattern:Tree -> accept 42 -//│ | > 2 is class:Pair -> λ λ -//│ | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ | > 1 is class:Pair -> λ λ -//│ | > 2 is null -> -//│ | > 1 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ | > 1 is class:Pair -> λ λ -//│ | > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | > 2 is class:Pair -> λ λ -//│ | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | > 2 is class:Pair -> λ λ -//│ | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | > 2 is class:Pair -> λ λ -//│ | > 2 is null -> -//│ | > 1 is null -> -//│ | > 3 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ | > 3 is class:Pair -> λ λ -//│ | > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | > 1 is class:Pair -> λ λ -//│ | > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | > 2 is class:Pair -> λ λ -//│ | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | > 2 is class:Pair -> λ λ -//│ | > 2 is null -> -//│ | > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ | > 1 is class:Pair -> λ λ -//│ | > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | > 2 is class:Pair -> λ λ -//│ | > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ | > 2 is class:Pair -> λ λ -//│ | > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ | found a recursive pattern -//│ normalize >>> -//│ > 1 is local:0 -> accept 42 -//│ memo: -//│ > 15 (0) => -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ > 7 (0) => -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ > 9 (0) => -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 13 (0) => -//│ > 1 is null -> -//│ > 3 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 12 (0) => -//│ > 2 is null -> -//│ > 1 is null -> -//│ > 3 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ > 2 (0) => -//│ > 2 is null -> 1 is local:0 -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is null -> -//│ > 3 is null -> accept 42 -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is null -> -//│ > 3 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ > 5 (0) => -//│ > 1 is null -> -//│ > 3 is null -> accept 42 -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 1 (0) => -//│ > 1 is class:Pair -> λ λ -//│ > 2 is null -> 1 is local:0 -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is null -> -//│ > 3 is null -> accept 42 -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is null -> -//│ > 3 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ > 17 (0) => -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ > 8 (0) => -//│ > 1 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 3 (0) => -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is null -> -//│ > 3 is null -> accept 42 -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is null -> -//│ > 3 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ > 4 (0) => -//│ > 2 is null -> -//│ > 1 is null -> -//│ > 3 is null -> accept 42 -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is null -> -//│ > 3 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ > 11 (0) => -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is null -> -//│ > 3 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ > 14 (0) => -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 6 (0) => -//│ > 3 is null -> accept 42 -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ > 0 (1) => -//│ > 1 is null -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is null -> 1 is local:0 -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is null -> -//│ > 3 is null -> accept 42 -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is null -> -//│ > 3 is pattern:Null -> 5 is pattern:Tree -> accept 42 -//│ > 3 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ > 16 (0) => -//│ > 2 is null -> -//│ > 1 is pattern:Null -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 1 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 7 is pattern:Tree -> 9 is pattern:Tree -> 11 is pattern:Tree -> accept 42 -//│ > 10 (0) => -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Null -> 1 is pattern:Tree -> 3 is pattern:Tree -> 7 is pattern:Tree -> accept 42 -//│ > 2 is class:Pair -> λ λ -//│ > 2 is pattern:Tree -> 1 is pattern:Tree -> 3 is pattern:Tree -> 5 is pattern:Tree -> 9 is pattern:Tree -> accept 42 -//│ FAILURE: Unexpected exception +:fixme +null is @compile Tree //│ /!!!\ Uncaught error: scala.MatchError: ClassLike(pattern:Tree) (of class hkmc2.semantics.ucs.PatternStub$ClassLike) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:265) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:258) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:258) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:258) -:cp -null ## null is Tree -//│ FAILURE: Unexpected exception +:fixme +null ## null is @compile Tree //│ /!!!\ Uncaught error: scala.MatchError: ClassLike(pattern:Tree) (of class hkmc2.semantics.ucs.PatternStub$ClassLike) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:265) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:258) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:258) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:258) -:cp -((null ## null) ## null) is Tree -//│ FAILURE: Unexpected exception +:fixme +((null ## null) ## null) is @compile Tree //│ /!!!\ Uncaught error: scala.MatchError: ClassLike(pattern:Tree) (of class hkmc2.semantics.ucs.PatternStub$ClassLike) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:265) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:258) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:258) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:258) -:cp -null ## (null ## null) is Tree -//│ FAILURE: Unexpected exception +:fixme +null ## (null ## null) is @compile Tree //│ /!!!\ Uncaught error: scala.MatchError: ClassLike(pattern:Tree) (of class hkmc2.semantics.ucs.PatternStub$ClassLike) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:265) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:258) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:258) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:258) -:cp -((null ## null) ## (null ## null)) is Tree -//│ FAILURE: Unexpected exception +:fixme +((null ## null) ## (null ## null)) is @compile Tree //│ /!!!\ Uncaught error: scala.MatchError: ClassLike(pattern:Tree) (of class hkmc2.semantics.ucs.PatternStub$ClassLike) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:265) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:258) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:258) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:255) -//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$11(DeBrujinSplit.scala:258) // Negative Test Cases // =================== @@ -775,22 +46,18 @@ null ## (null ## null) is Tree :global :expect false -// :cp -:todo -0 is Tree -//│ = false +:fixme +0 is @compile Tree +//│ /!!!\ Uncaught error: scala.MatchError: ClassLike(pattern:Tree) (of class hkmc2.semantics.ucs.PatternStub$ClassLike) -// :cp -:todo -0 ## 0 is Tree -//│ ═══[RUNTIME ERROR] Expected: false, got: true +:fixme +0 ## 0 is @compile Tree +//│ /!!!\ Uncaught error: scala.MatchError: ClassLike(pattern:Tree) (of class hkmc2.semantics.ucs.PatternStub$ClassLike) -// :cp -:todo -0 ## null is Tree -//│ ═══[RUNTIME ERROR] Expected: false, got: true +:fixme +0 ## null is @compile Tree +//│ /!!!\ Uncaught error: scala.MatchError: ClassLike(pattern:Tree) (of class hkmc2.semantics.ucs.PatternStub$ClassLike) -// :cp -:todo -null ## 0 is Tree -//│ ═══[RUNTIME ERROR] Expected: false, got: true +:fixme +null ## 0 is @compile Tree +//│ /!!!\ Uncaught error: scala.MatchError: ClassLike(pattern:Tree) (of class hkmc2.semantics.ucs.PatternStub$ClassLike) diff --git a/hkmc2/shared/src/test/mlscript/rp/recursion/SignBox.mls b/hkmc2/shared/src/test/mlscript/rp/recursion/SignBox.mls index b1d3fc1cb..4d2a54975 100644 --- a/hkmc2/shared/src/test/mlscript/rp/recursion/SignBox.mls +++ b/hkmc2/shared/src/test/mlscript/rp/recursion/SignBox.mls @@ -1,5 +1,4 @@ :js -:cp class Box[A](val value: A) @@ -10,27 +9,31 @@ pattern Sign = -1 | 0 | 1 pattern SignBox = Box(Sign | SignBox) -[Box(-1) is SignBox, Box(0) is SignBox, Box(1) is SignBox] +[ + Box(-1) is @compile SignBox, + Box(0) is @compile SignBox, + Box(1) is @compile SignBox +] //│ = [ true, true, true ] [ - Box(Box(-1)) is SignBox, - Box(Box(0)) is SignBox, - Box(Box(1)) is SignBox + Box(Box(-1)) is @compile SignBox, + Box(Box(0)) is @compile SignBox, + Box(Box(1)) is @compile SignBox ] //│ = [ true, true, true ] [ - Box(Box(Box(-1))) is SignBox, - Box(Box(Box(0))) is SignBox, - Box(Box(Box(1))) is SignBox + Box(Box(Box(-1))) is @compile SignBox, + Box(Box(Box(0))) is @compile SignBox, + Box(Box(Box(1))) is @compile SignBox ] //│ = [ true, true, true ] :expect [ false, false, false ] [ - Box(Box(Box(2))) is SignBox, - Box(Box(Box(null))) is SignBox, + Box(Box(Box(2))) is @compile SignBox, + Box(Box(Box(null))) is @compile SignBox, -1 is SignBox ] //│ = [ false, false, false ] diff --git a/hkmc2/shared/src/test/mlscript/rp/specialization/SimpleList.mls b/hkmc2/shared/src/test/mlscript/rp/specialization/SimpleList.mls index 362116996..f73a30345 100644 --- a/hkmc2/shared/src/test/mlscript/rp/specialization/SimpleList.mls +++ b/hkmc2/shared/src/test/mlscript/rp/specialization/SimpleList.mls @@ -1,5 +1,4 @@ :js -:cp class Pair[A, B](a: A, b: B) @@ -13,36 +12,30 @@ class Triplet[A, B, C](a: A, b: B, c: C) pattern Everything = _ -:cp -0 is Everything +0 is @compile Everything //│ = true pattern A = Box | Box -:cp -Box(0) is Box +Box(0) is @compile A //│ = true pattern BoxedAnswer = Box(42) -:cp -Box(42) is BoxedAnswer +Box(42) is @compile BoxedAnswer //│ = true pattern A_0 = Box(_) | Box(_) -:cp -Box(0) is A_0 +Box(0) is @compile A_0 //│ = true pattern A_1 = Box | Bowl -:cp -Box(0) is A_1 +Box(0) is @compile A_1 //│ = true -:cp -Bowl(0) is A_1 +Bowl(0) is @compile A_1 //│ = true pattern A_2 = _ | Box @@ -81,31 +74,26 @@ pattern F = Pair(Pair(Box, Bowl), Pair(Box, Basket)) pattern F_0 = Pair(Box, Bowl) -:cp :expect true -Pair(Box(42), Bowl(42)) is F_0 +Pair(Box(42), Bowl(42)) is @compile F_0 //│ = true pattern F_1 = Pair(Box, Box) | Pair(Box, Bowl) -:cp :expect true -Pair(Box(42), Box(42)) is F_1 +Pair(Box(42), Box(42)) is @compile F_1 //│ = true -:cp :expect true -Pair(Box(42), Bowl(42)) is F_1 +Pair(Box(42), Bowl(42)) is @compile F_1 //│ = true -:cp :expect false -Pair(Box(42), Basket(42)) is F_1 +Pair(Box(42), Basket(42)) is @compile F_1 //│ = false -:cp :expect false -Pair(Bowl(42), Bowl(42)) is F_1 +Pair(Bowl(42), Bowl(42)) is @compile F_1 //│ = false pattern G = Triplet(Triplet(Box, Bowl, Basket), Pair(0, 1), Basket) @@ -129,15 +117,14 @@ fun (::) cons(head, tail) = Pair(head, tail) 0 :: null //│ = Pair { a: 0, b: null } -:cp [ - null is BinSeq, - 0 :: null is BinSeq, - 0 :: 1 :: null is BinSeq, - 0 :: 1 :: 0 :: null is BinSeq, - 0 is BinSeq, - 1 is BinSeq, - 0 :: 1 :: 2 :: null is BinSeq, + null is @compile BinSeq, + 0 :: null is @compile BinSeq, + 0 :: 1 :: null is @compile BinSeq, + 0 :: 1 :: 0 :: null is @compile BinSeq, + 0 is @compile BinSeq, + 1 is @compile BinSeq, + 0 :: 1 :: 2 :: null is @compile BinSeq, ] //│ > [ //│ > true, true, @@ -146,8 +133,7 @@ fun (::) cons(head, tail) = Pair(head, tail) //│ > false //│ = ] -:cp -0 :: 1 :: 0 :: null is BinSeq +0 :: 1 :: 0 :: null is @compile BinSeq //│ = true :todo @@ -156,7 +142,5 @@ pattern List(a) = null | Pair(a, List) //│ ═══[ERROR] Unmatched number of captures and parameters. //│ /!!!\ Uncaught error: java.lang.AssertionError: assertion failed -// :cp -:todo -null is List +null is @compile List //│ = true diff --git a/hkmc2/shared/src/test/mlscript/rp/specialization/SimpleLiterals.mls b/hkmc2/shared/src/test/mlscript/rp/specialization/SimpleLiterals.mls index 7157e51ab..81cb839fb 100644 --- a/hkmc2/shared/src/test/mlscript/rp/specialization/SimpleLiterals.mls +++ b/hkmc2/shared/src/test/mlscript/rp/specialization/SimpleLiterals.mls @@ -1,31 +1,36 @@ :js -:cp pattern Zero = "0" pattern One = "1" pattern Two = "2" :ucs normalized +:fixme fun checkZeroOneTwo(x) = if x is - Zero then 0 - One then 1 - Two then 2 + @compile Zero then 0 + @compile One then 1 + @compile Two then 2 else () +//│ ╔══[ERROR] Unrecognized pattern split. +//│ ║ l.10: @compile Zero then 0 +//│ ╙── ^^^^^^^^^^^^^^^^^^^ +//│ ╔══[ERROR] Unrecognized pattern split. +//│ ║ l.11: @compile One then 1 +//│ ╙── ^^^^^^^^^^^^^^^^^^ +//│ ╔══[ERROR] Unrecognized pattern split. +//│ ║ l.12: @compile Two then 2 +//│ ╙── ^^^^^^^^^^^^^^^^^^ //│ Normalized: -//│ > if -//│ > x is "0" then 0 -//│ > x is "1" then 1 -//│ > x is "2" then 2 -//│ > else null +//│ > if then import "../../../mlscript-compile/Option.mls" open Option :ucs normalized fun checkSomeZeroOneTwo(x) = if x is - Some(Zero) then 0 - Some(One) then 1 - Some(Two) then 2 + Some(@compile Zero) then 0 + Some(@compile One) then 1 + Some(@compile Two) then 2 else () //│ Normalized: //│ > if @@ -38,6 +43,6 @@ fun checkSomeZeroOneTwo(x) = if x is pattern ManyZero = ("0" ~ (ManyZero | "")) | "" -let res = "1" is ManyZero +let res = "1" is @compile ManyZero //│ res = false diff --git a/hkmc2/shared/src/test/mlscript/syntax/annotations/Pattern.mls b/hkmc2/shared/src/test/mlscript/syntax/annotations/Pattern.mls index cba666633..4f564633f 100644 --- a/hkmc2/shared/src/test/mlscript/syntax/annotations/Pattern.mls +++ b/hkmc2/shared/src/test/mlscript/syntax/annotations/Pattern.mls @@ -2,8 +2,8 @@ module compile class SomePattern -:e // TODO: pattern compilation +:w fun foo(x) = if x is @compile SomePattern then "yes" else "no" -//│ ╔══[ERROR] Unrecognized pattern. +//│ ╔══[WARNING] Cannot compile the class `SomePattern` //│ ║ l.6: fun foo(x) = if x is @compile SomePattern then "yes" else "no" -//│ ╙── ^^^^^^^^^^^^^^^^^^^ +//│ ╙── ^^^^^^^^^^^