Skip to content

Commit aa182b1

Browse files
committed
Add test from ICFP interaction
1 parent 4a5a038 commit aa182b1

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

shared/src/test/diff/nu/Sidney.mls

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
:NewDefs
2+
3+
4+
fun swapMaybe(x, y) =
5+
if true then [x, y] else [y, x]
6+
//│ fun swapMaybe: forall 'a. ('a, 'a) -> ['a, 'a]
7+
8+
swapMaybe : forall 'a, 'b: ('a, 'b) -> ['a | 'b, 'b | 'a]
9+
//│ forall 'a. ('a, 'a) -> ['a, 'a]
10+
//│ res
11+
//│ = [Function: swapMaybe]
12+
13+
14+
fun test(x, y, z) =
15+
let xy = swapMaybe(x, y)
16+
let yz = swapMaybe(xy.1, z)
17+
[xy.0, yz.0, yz.1]
18+
//│ fun test: forall 'a 'b. ('a, 'a, 'b) -> ['a, 'a | 'b, 'b | 'a]
19+
20+
:e
21+
test : forall 'a, 'b: ('a, 'b, 'b) -> ['a | 'b, 'a | 'b, 'b]
22+
//│ ╔══[ERROR] Type mismatch in type ascription:
23+
//│ ║ l.21: test : forall 'a, 'b: ('a, 'b, 'b) -> ['a | 'b, 'a | 'b, 'b]
24+
//│ ║ ^^^^
25+
//│ ╟── type `'a` does not match type `'b`
26+
//│ ║ l.21: test : forall 'a, 'b: ('a, 'b, 'b) -> ['a | 'b, 'a | 'b, 'b]
27+
//│ ║ ^^
28+
//│ ╟── Note: constraint arises from type variable:
29+
//│ ║ l.21: test : forall 'a, 'b: ('a, 'b, 'b) -> ['a | 'b, 'a | 'b, 'b]
30+
//│ ║ ^^
31+
//│ ╟── Note: quantified type variable 'a is defined at:
32+
//│ ║ l.21: test : forall 'a, 'b: ('a, 'b, 'b) -> ['a | 'b, 'a | 'b, 'b]
33+
//│ ╙── ^^
34+
//│ forall 'a 'b. ('a, 'b, 'b) -> ['a | 'b, 'a | 'b, 'b]
35+
//│ res
36+
//│ = [Function: test]
37+
38+
39+
fun test(x, y, z) =
40+
if true then
41+
let xy = swapMaybe(x, y)
42+
[xy.0, xy.1, z]
43+
else
44+
let yz = swapMaybe(y, z)
45+
[x, yz.0, yz.1]
46+
//│ fun test: forall 'a 'b. ('a, 'a & 'b, 'b) -> ['a, 'a | 'b, 'b]
47+
48+
test : forall 'a: ('a, 'a, 'a) -> ['a, 'a, 'a]
49+
//│ forall 'a. ('a, 'a, 'a) -> ['a, 'a, 'a]
50+
//│ res
51+
//│ = [Function: test1]
52+
53+

0 commit comments

Comments
 (0)