Skip to content

Commit

Permalink
add test using existentials in pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
johnynek committed Nov 20, 2023
1 parent 5e0c63b commit d909317
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions core/src/test/scala/org/bykn/bosatsu/EvaluationTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3179,6 +3179,31 @@ res = match empty:
case [_, *_]: 1
test = Assertion(res matches 0, "one")
"""), "Foo", 1)

}

test("existential quantification in a match") {
runBosatsuTest(List("""
package Foo
enum FreeF[a]:
Pure(a: a)
Mapped(tup: exists b. (FreeF[b], b -> a))
def pure(a: a) -> FreeF[a]: Pure(a)
def map[a, b](f: FreeF[a], fn: a -> b) -> FreeF[b]:
tup: exists x. (FreeF[x], x -> b) = (f, fn)
Mapped(tup)
def run[a](fa: FreeF[a]) -> a:
recur fa:
case Pure(a): a
case Mapped((prev, fn)):
fn(run(prev))
res = run(pure(0).map(x -> x.add(1)))
test = Assertion(res matches 1, "one")
"""), "Foo", 1)

}
Expand Down

0 comments on commit d909317

Please sign in to comment.