Skip to content
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

Support for GADTs #195

Draft
wants to merge 95 commits into
base: mlscript
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
c4aa6d1
WIP Start implementing branch-local reasoning
LPTK Oct 3, 2023
261f9e0
refactor
Meowcolm024 Oct 5, 2023
816ea20
naive type member lookup
Meowcolm024 Oct 5, 2023
e7025e2
WIP type member partially works
Meowcolm024 Oct 16, 2023
6b2334e
WIP fixed name mangling ing TypeHelpers
Meowcolm024 Oct 17, 2023
5f18602
WIP refactor
Meowcolm024 Oct 17, 2023
b7e1bc7
TODO wildcard type and refinement
Meowcolm024 Oct 20, 2023
55eaa2a
added `as` keyword
Meowcolm024 Oct 25, 2023
270a859
WIP wildcard types
Meowcolm024 Oct 25, 2023
e201914
WIP
Meowcolm024 Nov 1, 2023
9566694
WIP
Meowcolm024 Nov 1, 2023
957b966
WIP added :GADTs flag
Meowcolm024 Nov 1, 2023
88b1af4
added GADT examples
Meowcolm024 Nov 3, 2023
ce83f9b
WIP update examples
Meowcolm024 Nov 3, 2023
cdf0f04
added some GADT examples
Meowcolm024 Nov 3, 2023
37a9de7
updated some examples and added some notes
Meowcolm024 Nov 3, 2023
570f3d7
WIP update tests
Meowcolm024 Nov 10, 2023
cb89a08
WIP
Meowcolm024 Nov 10, 2023
5150f53
Add an interesting test
LPTK Nov 10, 2023
28a831c
WIP move cache to ctx
Meowcolm024 Nov 17, 2023
aecd07e
Merge branch 'local-gadt' of github.com:Meowcolm024/mlscript into loc…
Meowcolm024 Nov 17, 2023
1e5b030
annot to trigger GADTs
Meowcolm024 Nov 28, 2023
1e87c13
clean up tests
Meowcolm024 Nov 28, 2023
3293b58
Merge remote-tracking branch 'hkust-taco/new-definition-typing' into …
Meowcolm024 Nov 28, 2023
a30e27d
clean up
Meowcolm024 Nov 28, 2023
a6c5451
fix lift
Meowcolm024 Nov 28, 2023
fa04070
add keyword "as" for asc
Meowcolm024 Dec 22, 2023
ecfde50
Merge remote-tracking branch 'hkust-taco/new-definition-typing' into …
Meowcolm024 Dec 27, 2023
13a0e85
cleanup
Meowcolm024 Dec 27, 2023
9f5d9b9
add more test cases
Meowcolm024 Dec 27, 2023
53e1352
Merge branch 'new-definition-typing' into local-gadt
Meowcolm024 Jan 3, 2024
ac25d4e
small test case change
Meowcolm024 Jan 3, 2024
6bfad52
add variance in type members decl
Meowcolm024 Jan 4, 2024
3104598
Merge branch 'new-definition-typing' into local-gadt
Meowcolm024 Jan 4, 2024
6c5975d
added more tests
Meowcolm024 Jan 4, 2024
fbd709f
added some multi param type tests
Meowcolm024 Jan 4, 2024
b77b47b
Merge remote-tracking branch 'origin/new-definition-typing' into loca…
Meowcolm024 Jan 15, 2024
e7b2c4c
wip
Meowcolm024 Jan 16, 2024
9c5e2c5
wip
Meowcolm024 Jan 17, 2024
2f193c8
WIP Prepare the grounds for SimpleTypeOrWildcard
LPTK Feb 2, 2024
f52774b
Fix bug in extrusion (extruded assigned TV level) and hack around pro…
LPTK Feb 2, 2024
1bb4b2d
wip
Meowcolm024 Feb 2, 2024
a017daa
Merge remote-tracking branch 'lptk/local-gadt-wip' into local-gadt-wip
Meowcolm024 Feb 2, 2024
61e8319
wip
Meowcolm024 Feb 2, 2024
e0c09ca
WIP wildcard
Meowcolm024 Feb 5, 2024
7868b3d
add more tests
Meowcolm024 Feb 5, 2024
2a633d2
wip: fixed some tests
Meowcolm024 Feb 6, 2024
17e8491
Add current type projection unsoundness example
LPTK Feb 3, 2024
f0b84c0
Push ascriptions inside branches for better type checking
LPTK Feb 7, 2024
9b73514
fixed parens
Meowcolm024 Feb 7, 2024
4f72058
wip err msg
Meowcolm024 Feb 7, 2024
80476ef
Minor: remove TODO
LPTK Feb 7, 2024
bb437ea
Fix freak condition in freshening
LPTK Feb 7, 2024
e4bff8c
Merge branch 'mlscript' into local-gadt (one test now fails)
LPTK Feb 7, 2024
dce34e4
Make test green; not sure why it now fails
LPTK Feb 7, 2024
462804a
wip various fixed
Meowcolm024 Feb 8, 2024
c6491bd
WIP correct polarity/variance treatment of WildcardArg
Meowcolm024 Feb 8, 2024
db7f38a
WIP Move towards a correct handling of WildcardArg
LPTK Feb 8, 2024
8ee5a84
Add alias GADT use case
LPTK Feb 13, 2024
4b129aa
various small fixes
Meowcolm024 Feb 14, 2024
79e3f0f
change typing of type member alias
Meowcolm024 Feb 14, 2024
8defef6
implement parser for type argument bounds
Meowcolm024 Feb 14, 2024
05b68c0
small format fix
Meowcolm024 Feb 16, 2024
73d970a
WIP added test case similar to the zip one
Meowcolm024 Feb 17, 2024
f8784ac
wip change tag checking in <:< for LhsNf
Meowcolm024 Feb 26, 2024
0f9e788
wip: self type sig issue
Meowcolm024 Feb 26, 2024
7a0353f
WIP early finish some dnfs
Meowcolm024 Feb 28, 2024
cf228b0
wip change extr type args
Meowcolm024 Feb 29, 2024
4f24921
add prov for wildcard
Meowcolm024 Mar 1, 2024
6e6b9a1
WIP refactor wildcard
Meowcolm024 Mar 4, 2024
a7e3b94
WIP fix various crashes
Meowcolm024 Mar 4, 2024
625fafe
WIP fix standalone wildcard typing
Meowcolm024 Mar 4, 2024
3c05aee
wip expand alias issue
Meowcolm024 Mar 4, 2024
e13bff7
wip fix pol
Meowcolm024 Mar 5, 2024
71d9232
wip fix alias ty arg extursion
Meowcolm024 Mar 5, 2024
0b766ce
wip early finish dnf solving for other tags
Meowcolm024 Mar 5, 2024
e667617
wip fix extr for alias and updated some tests
Meowcolm024 Mar 5, 2024
2b27281
small fix
Meowcolm024 Mar 6, 2024
2bc5cf8
simple level indexed extrusion cache
Meowcolm024 Mar 6, 2024
d268965
WIP replace incorrect use of mapTargs and avoid level-mismatched cons…
LPTK Mar 15, 2024
031f611
WW
LPTK Mar 15, 2024
95f4cb7
WWW
LPTK Mar 15, 2024
60c4b74
WWW
LPTK Mar 15, 2024
ab4b456
WWW
LPTK Mar 15, 2024
27c2354
WWW
LPTK Mar 15, 2024
ab2fe6b
WW
LPTK Mar 15, 2024
03044b8
WW fix extruded compare
LPTK Mar 15, 2024
2f636e5
W simplify YC's mess
LPTK Mar 15, 2024
7b89780
WWW trial
LPTK Mar 15, 2024
95a3620
W
LPTK Mar 16, 2024
54ba6ad
W
LPTK Mar 18, 2024
db2fb45
Minor
LPTK Apr 2, 2024
e24d01e
Merge remote-tracking branch 'origin/mlscript' into local-gadt
Meowcolm024 Apr 9, 2024
064f004
add some test cases
Meowcolm024 Apr 12, 2024
9ef9425
fix some test cases
Meowcolm024 Apr 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shared/src/main/scala/mlscript/NewParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ abstract class NewParser(origin: Origin, tokens: Ls[Stroken -> Loc], newDefs: Bo
}
val lb = getTypeName("restricts")
val ub = getTypeName("extends")

// TODO update `TypeParamInfo` to use lb and ub
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

yeetSpaces match {
case (COMMA, l0) :: _ =>
consume
Expand Down
9 changes: 8 additions & 1 deletion shared/src/main/scala/mlscript/NormalForms.scala
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,14 @@ class NormalForms extends TyperDatatypes { self: Typer =>
case (LhsTop, _) => false
case (LhsRefined(b1, ts1, rt1, trs1), LhsRefined(b2, ts2, rt2, trs2)) =>
b2.forall(b2 => b1.exists(_ <:< b2)) &&
ts2.forall(ts1) && rt1 <:< rt2 &&
ts2.forall {
case sk: SkolemTag => ts1(sk)
case tt: TraitTag => ts1(tt)
case Extruded(pol, sk) => !pol || ts1.exists { // find ? <: bot
case Extruded(true, _) => true
case _ => false
}
} && rt1 <:< rt2 &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This thing looks very fishy. What is going on here? Why don't we use the normal set functions?

trs2.valuesIterator.forall(tr2 => trs1.valuesIterator.exists(_ <:< tr2))
}
def isTop: Bool = isInstanceOf[LhsTop.type]
Expand Down
1 change: 1 addition & 0 deletions shared/src/main/scala/mlscript/NuTypeDefs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,7 @@ class NuTypeDefs extends ConstraintSolver { self: Typer =>
println(s"baseClsImplemMembers ${baseClsImplemMembers}")

val newImplems = ttu.implementedMembers.map {
// * transform type alias member to type member
case als: TypedNuAls =>
if (tparamFields.map(_._1.name).contains(als.name))
err(msg"Class type member '${als.name}' already exists", als.toLoc)
Expand Down
22 changes: 11 additions & 11 deletions shared/src/test/diff/ecoop23/PolymorphicVariants.mls
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ mixin EvalExpr {
}
//│ mixin EvalExpr() {
//│ super: {eval: ('a, Var) -> 'b}
//│ this: {eval: ('a, ??A & 'A | ??A0 & 'A0) -> (Object | ~??A1 & ~??A2)}
//│ this: {eval: ('a, ??A & 'A | ??A0 & 'A0) -> (Object | ~??A1)}
//│ fun eval: ('a, 'b & (Add['A] | Mul['A0] | Numb | Var)) -> (Numb | 'b)
//│ }

Expand Down Expand Up @@ -191,7 +191,7 @@ Test2.eval(Cons(["c", Abs("d", Var("d"))], Nil), Abs("a", Var("a")))
//│ Error: non-exhaustive case expression

Test2.eval(Cons(["a", Abs("d", Var("d"))], Nil), Add(Numb(1), Var("a")))
//│ Abs[Var] & ??A | Add[Numb | Var] | Numb | Var
//│ Abs[Var] & ??A | Add[Numb | Var] | Numb & ??A0 | Var
//│ res
//│ = Add {}

Expand All @@ -201,23 +201,23 @@ module Test3 extends EvalVar, EvalExpr, EvalLambda
//│ }
//│ where
//│ 'A :> 'b
//│ <: Object | ~(??A0 & (??A1 | ??A2))
//│ <: Object | ~(??A0 & ??A1)
//│ 'b :> App[nothing] | Abs[nothing] | Numb | Var | ??A0 & 'A | 'a
//│ 'a <: Add[Abs['A0] | App['A1] | 'a & (Object & ~#Abs & ~#App | ~#Abs & ~#App & ~??A3) | ~??A3] | Mul[Abs['A0] | App['A1] | 'a & (Object & ~#Abs & ~#App | ~#Abs & ~#App & ~??A4) | ~??A4] | Numb | Var
//│ 'A0 <: Abs['A0] | App['A1] | 'a & (Object & ~#Abs & ~#App | ~#Abs & ~#App & ~??A5) | ~??A5
//│ 'A1 <: Abs['A0 & (Abs['A0] | App['A1] | Object & 'a & ~#Abs & ~#App | ~??A6)] | Abs['A0] & ~#Abs | App['A1] | Object & 'a & ~#Abs & ~#App | ~??A7
//│ 'a <: Add[Abs['A0] | App['A1] | 'a & (Object & ~#Abs & ~#App | ~#Abs & ~#App & ~??A2) | ~??A2] | Mul[Abs['A0] | App['A1] | 'a & (Object & ~#Abs & ~#App | ~#Abs & ~#App & ~??A3) | ~??A3] | Numb | Var
//│ 'A0 <: Abs['A0] | App['A1] | 'a & (Object & ~#Abs & ~#App | ~#Abs & ~#App & ~??A4) | ~??A4
//│ 'A1 <: Abs['A0 & (Abs['A0] | App['A1] | Object & 'a & ~#Abs & ~#App | ~??A5)] | Abs['A0] & ~#Abs | App['A1] | Object & 'a & ~#Abs & ~#App | ~??A6

Test3.eval(Cons(["c", Abs("d", Var("d"))], Nil), Abs("a", Var("a")))
//│ 'a
//│ where
//│ 'a :> App['a] | Abs['a] | Abs[Var] & ??A | Numb | Var
//│ 'a :> App['a] | Abs['a] | Abs[Var] & ??A | Numb | Var & ??A0
//│ res
//│ = Abs {}

Test3.eval(Cons(["c", Abs("d", Var("d"))], Nil), App(Abs("a", Var("a")), Add(Numb(1), Var("c"))))
//│ 'a
//│ where
//│ 'a :> App['a] | Abs['a] | Abs[Var] & ??A | Add[Numb | Var] & ??A0 | Numb | Numb & ??A1 | Var
//│ 'a :> App['a] | Abs['a] | Abs[Var] & ??A | Add[Numb | Var] & ??A0 | Numb & ??A1 | Var & ??A2
//│ res
//│ = Add {}

Expand All @@ -228,7 +228,7 @@ module Test3 extends EvalVar, EvalLambda, EvalExpr
//│ }
//│ where
//│ 'A :> ??A0 & 'A0 | ??A1 & 'A1 | 'a
//│ <: Object | ~(??A2 & (??A3 | ??A4))
//│ <: Object | ~(??A2 & ??A3)
//│ 'a :> Abs[nothing] | App[nothing] | Numb | Var | ??A0 & 'A0 | ??A1 & 'A1 | ??A2 & 'A
//│ 'A0 <: Add['A0] | Mul['A1] | Numb | Var | ~??A0
//│ 'A1 <: Add['A0] | Mul['A1] | Numb | Var | ~??A1
Expand All @@ -249,9 +249,9 @@ Test3.eval(Cons(["c", Abs("d", Var("d"))], Nil), Abs("a", Var("a")))
//│ ╟── from reference:
//│ ║ l.137: let vv = map_expr(eta, v)
//│ ╙── ^
//│ Abs[Var] | error | 'a
//│ Abs[Var] | Numb | error | 'a
//│ where
//│ 'a :> Abs[Var | 'a] | Abs[Var] & ??A | App['a] | Numb | Var
//│ 'a :> Abs[Var | 'a] | App['a] | Var | ??A & (Abs[Var] | Numb)
//│ res
//│ Runtime error:
//│ Error: non-exhaustive case expression
Expand Down
4 changes: 2 additions & 2 deletions shared/src/test/diff/ecoop23/SimpleRegionDSL_raw.mls
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,9 @@ module TestElim extends Eliminate
//│ 'Region3 <: Intersect['Region] | Outside['Region0] | Scale['Region1] | Translate['Region2] | Union['Region3] | 'a & (Object & ~#Intersect & ~#Outside & ~#Scale & ~#Translate & ~#Union | ~#Intersect & ~#Outside & ~#Scale & ~#Translate & ~#Union & ~??Region4) | ~??Region4

TestElim.eliminate(Outside(Outside(Univ())))
//│ Univ & ??Region | Univ & ??Region0 | 'a
//│ Univ & ??Region | 'a
//│ where
//│ 'a :> Univ & ??Region | Univ & ??Region0 | Scale[Univ & ??Region | Univ & ??Region0 | 'a] | Outside[Univ & ??Region | Univ & ??Region0 | 'a] | Union[Univ & ??Region | Univ & ??Region0 | 'a] | Intersect[Univ & ??Region | Univ & ??Region0 | 'a] | Translate[Univ & ??Region | Univ & ??Region0 | 'a]
//│ 'a :> Univ & ??Region | Scale[Univ & ??Region | 'a] | Outside[Univ & ??Region | 'a] | Union[Univ & ??Region | 'a] | Intersect[Univ & ??Region | 'a] | Translate[Univ & ??Region | 'a]
//│ res
//│ = Univ {}

Expand Down
2 changes: 1 addition & 1 deletion shared/src/test/diff/fcp-lit/QML.mls
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def step = fun xx -> xx (fun ((((xinit, xsub), xupdate), xfold),) ->

let mkArray n = if n == 0 then base else step base in
mkArray 1 (fun ((((xinit, xsub), xupdate), xfold),) -> xinit 2)
//│ res: ??r | ??r0
//│ res: ??r
//│ = [ 2, 2 ]

def mkArray : int -> ExSig
Expand Down
4 changes: 2 additions & 2 deletions shared/src/test/diff/fcp/Aleks.mls
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ r1 id
//│ ╟── Note: constraint arises from type variable:
//│ ║ l.18: def foo: forall 'x. ('x -> 'x, 'x -> 'x)
//│ ╙── ^^
//│ res: error | 'a -> 'a | ??y
//│ res: ??y

:e
r2 id
Expand All @@ -72,6 +72,6 @@ r2 id
//│ ╟── Note: constraint arises from type variable:
//│ ║ l.18: def foo: forall 'x. ('x -> 'x, 'x -> 'x)
//│ ╙── ^^
//│ res: error | 'a -> 'a | ??y
//│ res: ??y


44 changes: 22 additions & 22 deletions shared/src/test/diff/fcp/QML_exist_Classes.mls
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ sb (fun arr1 -> sb (fun arr2 -> arr2.Update (arr1.Init true)))
//│ ╟── Note: constraint arises from application:
//│ ║ l.234: sb (fun arr1 -> sb (fun arr2 -> arr2.Update (arr1.Init true)))
//│ ╙── ^^^^^^^^^^^^^^
//│ res: error | int -> anything -> (??Rep | ??Rep0)
//│ res: error | int -> anything -> ??Rep
//│ = [Function (anonymous)]

sb (fun arr ->
Expand All @@ -270,20 +270,20 @@ sb (fun arr ->

:e
def simpleStep arr = arr (fun impl -> fun k -> k (simpleStepImpl impl))
//│ ((forall 'Rep 'a 'A 'c 'A0 'd 'Rep0 'A1. ArraysRep[in 'A1 & 'A & 'A0 out 'A | 'A1, in 'Rep0 & 'Rep & 'c out 'Rep0 | 'Rep] -> ((forall 'Rep1. ArraysImpl['A0, 'Rep1] with {
//│ fold: forall 'b. ('A -> 'b -> 'b) -> 'b -> (('Rep, anything,),) -> 'b,
//│ init: 'A1 -> ('Rep0, "initialized",),
//│ sub: (('Rep, anything,),) -> int -> 'A,
//│ update: forall 'e. (('Rep & 'e, anything,),) -> int -> 'A1 -> ('Rep0 | 'e, "updated",)
//│ }) -> 'a) -> 'a) -> 'f) -> 'f
//│ ((forall 'Rep 'A 'Rep0 'a 'c 'A0 'A1 'd. ArraysRep[in 'A & 'A1 & 'A0 out 'A1 | 'A, in 'Rep & 'Rep0 & 'a out 'Rep | 'Rep0] -> ((forall 'Rep1. ArraysImpl['A0, 'Rep1] with {
//│ fold: forall 'b. ('A1 -> 'b -> 'b) -> 'b -> (('Rep0, anything,),) -> 'b,
//│ init: 'A -> ('Rep, "initialized",),
//│ sub: (('Rep0, anything,),) -> int -> 'A1,
//│ update: forall 'e. (('Rep0 & 'e, anything,),) -> int -> 'A -> ('Rep | 'e, "updated",)
//│ }) -> 'c) -> 'c) -> 'f) -> 'f
//│ where
//│ 'Rep1 :> ('Rep0 | 'd, "initialized" | "updated",)
//│ <: ('Rep & 'c, anything,)
//│ 'c <: 'Rep & 'd
//│ 'd :> 'Rep0
//│ <: 'Rep & 'c
//│ 'A0 :> 'A
//│ <: 'A1
//│ 'Rep1 :> ('Rep | 'd, "initialized" | "updated",)
//│ <: ('Rep0 & 'a, anything,)
//│ 'a <: 'Rep0 & 'd
//│ 'd :> 'Rep
//│ <: 'Rep0 & 'a
//│ 'A0 :> 'A1
//│ <: 'A
//│ <: simpleStep:
//│ Arrays['a] -> Arrays['a]
//│ ╔══[ERROR] Type error in def definition
Expand Down Expand Up @@ -383,10 +383,10 @@ def stepImpl arrImpl = ArraysImpl {
fold = fun f -> fun b -> fun ((r0, r1)) -> arrImpl.Fold f (arrImpl.Fold f b r0) r1
}
//│ stepImpl: ArraysRep[in 'A & 'A0 & 'A1 out 'A0 | 'A, in 'Rep & 'Rep0 & 'a & 'c out 'Rep | 'Rep0] -> (ArraysImpl['A1, 'Rep1] with {
//│ fold: forall 'b 'b0. ('A0 -> 'b0 -> 'b0 & 'A0 -> 'b -> ('b0 & 'b)) -> ('b0 & 'b) -> (('Rep0, 'Rep0,),) -> 'b0,
//│ fold: forall 'b 'b0. ('A0 -> 'b -> 'b & 'A0 -> 'b0 -> ('b & 'b0)) -> ('b & 'b0) -> (('Rep0, 'Rep0,),) -> 'b,
//│ init: 'A -> ('Rep, 'Rep,),
//│ sub: (('Rep0, 'Rep0,),) -> int -> 'A0,
//│ update: forall 'd 'e. (('Rep0 & 'd, 'Rep0 & 'e,),) -> int -> 'A -> ('Rep | 'd, 'Rep | 'e,)
//│ update: forall 'd 'e. (('Rep0 & 'e, 'Rep0 & 'd,),) -> int -> 'A -> ('Rep | 'e, 'Rep | 'd,)
//│ })
//│ where
//│ 'Rep1 :> ('Rep | 'a | 'f, 'Rep | 'c | 'g,)
Expand All @@ -407,11 +407,11 @@ def step: Arrays['a] -> Arrays['a]
//│ = <missing implementation>

def step arr = arr (fun impl -> fun (k: ArraysRepConsumer['a, 'r]) -> k (stepImpl impl))
//│ ((forall 'Rep 'a 'A 'A0 'A1. ArraysRep[in 'A & 'A0 & 'A1 out 'A | 'A0, 'Rep] -> ArraysRepConsumer['A, 'a] -> 'a) -> 'b) -> 'b
//│ ((forall 'A 'A0 'Rep 'a 'A1. ArraysRep[in 'A1 & 'A & 'A0 out 'A1 | 'A, 'Rep] -> ArraysRepConsumer['A1, 'a] -> 'a) -> 'b) -> 'b
//│ where
//│ 'A :> 'A0
//│ <: 'A1
//│ 'A1 <: 'A
//│ 'A1 :> 'A
//│ <: 'A0
//│ 'A0 <: 'A1
//│ <: step:
//│ Arrays['a] -> Arrays['a]
//│ = [Function: step]
Expand Down Expand Up @@ -462,7 +462,7 @@ snb = mkMonoArray 5
//│ = [Function (anonymous)]

snb (fun arr -> arr.Init true)
//│ res: ??Rep | ??Rep0
//│ res: ??Rep
//│ = [
//│ [ [ [Array], [Array] ], [ [Array], [Array] ] ],
//│ [ [ [Array], [Array] ], [ [Array], [Array] ] ]
Expand All @@ -479,7 +479,7 @@ snb = mkMonoArray 5
//│ = [Function (anonymous)]

snb (fun arr -> arr.Init true)
//│ res: ??Rep | ??Rep0
//│ res: ??Rep
//│ = [ [ [ [Array], 'initialized' ], 'initialized' ], 'initialized' ]


Expand Down
16 changes: 8 additions & 8 deletions shared/src/test/diff/fcp/QML_exist_Records_D.mls
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ snb = mkMonoArray 3

// * Here we are trying to leak the internally-quantified representation, resulting in `anything` being returned
snb (fun arr -> arr.init true)
//│ res: ??rep | ??rep0
//│ res: ??rep
//│ = [ [ [ true, 'hi' ], 'hi' ], 'hi' ]


Expand Down Expand Up @@ -266,7 +266,7 @@ snb = mkMonoArray 3

// * Here we are trying to leak the internally-quantified representation, resulting in `anything` being returned
snb (fun arr -> arr.init true)
//│ res: ??rep | ??rep0
//│ res: ??rep
//│ = [ [ [ true, 'hi' ], 'hi' ], 'hi' ]


Expand Down Expand Up @@ -363,20 +363,20 @@ def step arr = arr (forall 'a. fun impl -> forall 'r. fun (k: ArraysImplConsumer

// * ...unless we use `stepImpl_ty` instead of `stepImpl`
def step arr = arr (fun impl -> forall 'r. fun (k: ArraysImplConsumer['a, 'r]) -> k (stepImpl_ty impl))
//│ ((forall 'r 'a 'r0 'a0 'a1. ArraysImpl[in 'a0 & 'a1 out 'a0 | 'a1, 'r0] -> ArraysImplConsumer['a, 'r] -> 'r) -> 'b) -> 'b
//│ ((forall 'a 'a0 'r 'r0 'a1. ArraysImpl[in 'a & 'a0 out 'a | 'a0, 'r] -> ArraysImplConsumer['a1, 'r0] -> 'r0) -> 'b) -> 'b
//│ where
//│ 'a :> 'a0
//│ <: 'a1
//│ 'a1 :> 'a
//│ <: 'a0
//│ <: step:
//│ Arrays['a] -> Arrays['a]
//│ = [Function: step8]


def step arr = arr (fun impl -> (fun k -> k (stepImpl impl)) : Arrays['a])
//│ ((forall 'a 'a0 'r. ArraysImpl[in 'a out 'a | 'a0, 'r] -> Arrays['a]) -> 'b) -> 'b
//│ ((forall 'a 'a0 'r. ArraysImpl[in 'a & 'a0 out 'a, 'r] -> Arrays['a0]) -> 'b) -> 'b
//│ where
//│ 'a := 'a0
//│ 'a0 :> 'a
//│ 'a :> 'a0
//│ 'a0 := 'a
//│ <: step:
//│ Arrays['a] -> Arrays['a]
//│ = [Function: step9]
Expand Down
20 changes: 10 additions & 10 deletions shared/src/test/diff/fcp/QML_exist_Records_ND.mls
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ snb = mkMonoArray 3

// * Here we are trying to leak the internally-quantified representation, resulting in extruded types being returned
snb (fun arr -> arr.init true)
//│ res: ??rep | ??rep0
//│ res: ??rep
//│ = [ [ [ true, 'hi' ], 'hi' ], 'hi' ]


Expand Down Expand Up @@ -583,19 +583,19 @@ def s arr (k: ArraysImplConsumer['a, 'rep]) = arr (fun impl -> k (stepImpl_ty im
// * We can see it shouldn't be simplified to nothing:
:ns
s
//│ res: forall 'b 'a 'a0 'rep 'c. 'c -> (forall 'd 'a1 'rep0. ArraysImplConsumer['a1, 'rep0] -> 'd)
//│ res: forall 'a 'b 'c 'rep 'a0. 'b -> (forall 'd 'a1 'rep0. ArraysImplConsumer['a1, 'rep0] -> 'd)
//│ where
//│ 'd :> 'b
//│ 'd :> 'c
//│ 'rep0 <: 'rep
//│ 'a1 :> 'a0
//│ <: 'a
//│ 'c <: (forall 'e 'a2 'f 'r. 'e -> 'f) -> 'b
//│ 'a1 :> 'a
//│ <: 'a0
//│ 'b <: (forall 'e 'a2 'f 'r. 'e -> 'f) -> 'c
//│ 'f :> 'rep
//│ 'e <: ArraysImpl['a2, 'r]
//│ 'a2 :> 'a
//│ <: 'a0
//│ 'a <: 'a0
//│ 'a2 :> 'a0
//│ <: 'a
//│ 'a0 <: 'a
//│ 'a <: 'a0
//│ = [Function: s]

// * BTW: this doesn't work (same reason as before: k needs an annotation)
Expand Down Expand Up @@ -650,7 +650,7 @@ snb = mkMonoArray 3

// * Here we are trying to leak the internally-quantified representation, resulting in extruded types being returned
snb (fun arr -> arr.init true)
//│ res: ??rep | ??rep0
//│ res: ??rep
//│ = [ [ [ true, 'hi' ], 'hi' ], 'hi' ]


Expand Down
4 changes: 2 additions & 2 deletions shared/src/test/diff/fcp/QML_exist_nu.mls
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ snb.use of impl =>
// * Here we are trying to leak the internally-quantified representation, resulting in the `??rep` extrusion
snb.use of impl => impl.init(true)
// :d
//│ true | ??rep
//│ ??rep
//│ res
//│ = [
//│ [ [ true, true ], [ true, true ] ],
Expand Down Expand Up @@ -329,7 +329,7 @@ snb.use of impl =>
//│ ]

snb.use of impl => impl.init(true)
//│ true | ??rep
//│ ??rep
//│ res
//│ = [
//│ [ [ true, true ], [ true, true ] ],
Expand Down
Loading