Skip to content

Commit cc87059

Browse files
committed
Changes from meeting
1 parent 9707a3f commit cc87059

File tree

2 files changed

+75
-6
lines changed

2 files changed

+75
-6
lines changed

hkmc2/shared/src/main/scala/hkmc2/bbml/NormalForm.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ extends NormalForm with CachedBasicType:
126126
case (cls1, cls2) => cls1.name.uid <= cls2.name.uid
127127
}.foldLeft[Ls[ClassLikeType]](Nil)((res, cls) => (res, cls) match {
128128
case (Nil, cls) => cls :: Nil
129-
case (ClassLikeType(cls1, targs1) :: tail, ClassLikeType(cls2, targs2)) if cls1.uid === cls2.uid =>
129+
case (ClassLikeType(cls1, targs1) :: tail, ClassLikeType(cls2, targs2)) if cls1.uid === cls2.uid =>
130130
ClassLikeType(cls1, targs1.lazyZip(targs2).map(_ | _)) :: tail
131131
case (head :: tail, cls) => cls :: head :: tail
132132
}))

hkmc2/shared/src/test/mlscript/bbml/DisjSub.mls

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
//│ Type: ⊤
55

6+
67
fun andt(x)=x&&true
78
fun k(f:Nothing->Bool)=1
89
fun ap(f)=x=>f(x)
@@ -14,20 +15,88 @@ k(andt)
1415
k(ap(andt))
1516
//│ Type: Int
1617

17-
fun id:(Int->Int)&(Bool->Bool)
18+
k(k)
19+
//│ Type: Int
20+
21+
fun idIB: (Int -> Int) & (Bool -> Bool)
1822
//│ Type: ⊤
1923

20-
id(1)
24+
idIB(1)
2125
//│ Type: Int
2226

27+
idIB(true)
28+
//│ Type: Bool
29+
30+
idIB(if true then 1 else true)
31+
//│ Type: Bool ∨ Int
32+
33+
2334
fun ap1(f)=f(1)
24-
ap1(id)
35+
ap1(idIB)
2536
//│ Type: Int
2637

27-
ap(id)(1)
38+
ap(idIB)(1)
2839
//│ Type: Int
2940

3041
:todo
31-
x=>id(x)
42+
x=>idIB(x)
3243
//│ Type: (Int ∨ Bool) ->{⊥} ⊥
3344

45+
46+
:todo // BbML
47+
fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
48+
//│ ╔══[ERROR] General type is not allowed here.
49+
//│ ║ l.47: fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
50+
//│ ╙── ^^^
51+
//│ ╔══[ERROR] General type is not allowed here.
52+
//│ ║ l.47: fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
53+
//│ ╙── ^^^^
54+
//│ Type: ⊤
55+
56+
:todo // BbML
57+
idIIBB([1, 2])
58+
//│ ╔══[ERROR] Term shape not yet supported by BbML: Tup(List(Fld(‹›,Lit(IntLit(1)),None), Fld(‹›,Lit(IntLit(2)),None)))
59+
//│ ║ l.57: idIIBB([1, 2])
60+
//│ ╙── ^^^^^^
61+
//│ Type: ⊥
62+
63+
64+
class Pair[out A, out B](fst: A, snd: B)
65+
//│ Type: ⊤
66+
67+
new Pair(1, 2)
68+
//│ Type: Pair['A, 'B]
69+
//│ Where:
70+
//│ Int <: 'A
71+
//│ Int <: 'B
72+
73+
:todo // WF check on intersection types
74+
:e
75+
fun idIIBB: (Pair[Int, Int] -> Int) & (Pair[Bool, Bool] -> Bool)
76+
//│ Type: ⊤
77+
78+
idIIBB(new Pair(1, 2))
79+
//│ Type: Bool ∨ Int
80+
81+
idIIBB(new Pair(1, true))
82+
//│ Type: Bool ∨ Int
83+
84+
85+
86+
:todo
87+
fun foo: ["x": Int, "y": Int]
88+
//│ ╔══[ERROR] Invalid type
89+
//│ ║ l.87: fun foo: ["x": Int, "y": Int]
90+
//│ ╙── ^^^^^^^^^^^^^^^^^^^^
91+
//│ Type: ⊤
92+
93+
foo
94+
//│ Type: ⊥
95+
96+
:todo
97+
fun foo(x) = if x is
98+
[true, true] then 1
99+
[false, false] then 2
100+
//│ /!!!\ Uncaught error: scala.MatchError: Tuple(2,false) (of class hkmc2.semantics.Pattern$Tuple)
101+
102+

0 commit comments

Comments
 (0)