Skip to content

Commit

Permalink
Add test from ICFP interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
LPTK committed Sep 12, 2024
1 parent 4a5a038 commit aa182b1
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions shared/src/test/diff/nu/Sidney.mls
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
:NewDefs


fun swapMaybe(x, y) =
if true then [x, y] else [y, x]
//│ fun swapMaybe: forall 'a. ('a, 'a) -> ['a, 'a]

swapMaybe : forall 'a, 'b: ('a, 'b) -> ['a | 'b, 'b | 'a]
//│ forall 'a. ('a, 'a) -> ['a, 'a]
//│ res
//│ = [Function: swapMaybe]


fun test(x, y, z) =
let xy = swapMaybe(x, y)
let yz = swapMaybe(xy.1, z)
[xy.0, yz.0, yz.1]
//│ fun test: forall 'a 'b. ('a, 'a, 'b) -> ['a, 'a | 'b, 'b | 'a]

:e
test : forall 'a, 'b: ('a, 'b, 'b) -> ['a | 'b, 'a | 'b, 'b]
//│ ╔══[ERROR] Type mismatch in type ascription:
//│ ║ l.21: test : forall 'a, 'b: ('a, 'b, 'b) -> ['a | 'b, 'a | 'b, 'b]
//│ ║ ^^^^
//│ ╟── type `'a` does not match type `'b`
//│ ║ l.21: test : forall 'a, 'b: ('a, 'b, 'b) -> ['a | 'b, 'a | 'b, 'b]
//│ ║ ^^
//│ ╟── Note: constraint arises from type variable:
//│ ║ l.21: test : forall 'a, 'b: ('a, 'b, 'b) -> ['a | 'b, 'a | 'b, 'b]
//│ ║ ^^
//│ ╟── Note: quantified type variable 'a is defined at:
//│ ║ l.21: test : forall 'a, 'b: ('a, 'b, 'b) -> ['a | 'b, 'a | 'b, 'b]
//│ ╙── ^^
//│ forall 'a 'b. ('a, 'b, 'b) -> ['a | 'b, 'a | 'b, 'b]
//│ res
//│ = [Function: test]


fun test(x, y, z) =
if true then
let xy = swapMaybe(x, y)
[xy.0, xy.1, z]
else
let yz = swapMaybe(y, z)
[x, yz.0, yz.1]
//│ fun test: forall 'a 'b. ('a, 'a & 'b, 'b) -> ['a, 'a | 'b, 'b]

test : forall 'a: ('a, 'a, 'a) -> ['a, 'a, 'a]
//│ forall 'a. ('a, 'a, 'a) -> ['a, 'a, 'a]
//│ res
//│ = [Function: test1]


0 comments on commit aa182b1

Please sign in to comment.