Skip to content

Commit 8bad1a5

Browse files
committed
Changes from meeting
1 parent aa956a7 commit 8bad1a5

File tree

2 files changed

+51
-17
lines changed

2 files changed

+51
-17
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,25 +287,25 @@ object Type:
287287
if !prev.contains(a -> b) then c.getOrElseUpdate(a -> b, {
288288
(a, b) match
289289
case (Bot, _) | (_, Bot) => S(Set.empty)
290-
case (NegType(t),_) => t.toBasic.!.simp.toBasic match
290+
case (NegType(t),_) => t.!.simp.toBasic match
291291
case NegType(_) => N
292292
case a => disjoint(a, b)(prev)
293-
case (_, NegType(t)) => t.toBasic.!.simp.toBasic match
293+
case (_, NegType(t)) => t.!.simp.toBasic match
294294
case NegType(_) => N
295295
case a => disjoint(a, b)(prev)
296296
case (ClassLikeType(a, _), ClassLikeType(b, _)) if a.uid =/= b.uid => S(Set.empty)
297297
case (ComposedType(p, q, true), _) =>
298-
val u = disjoint(p.toBasic.simp.toBasic, b)(prev)
299-
val w = disjoint(q.toBasic.simp.toBasic, b)(prev)
298+
val u = disjoint(p.simp.toBasic, b)(prev)
299+
val w = disjoint(q.simp.toBasic, b)(prev)
300300
u.flatMap(u => w.map(u ++ _))
301301
case (_, ComposedType(p, q, true)) =>
302-
val u = disjoint(a, p.toBasic.simp.toBasic)(prev)
303-
val w = disjoint(a, q.toBasic.simp.toBasic)(prev)
302+
val u = disjoint(a, p.simp.toBasic)(prev)
303+
val w = disjoint(a, q.simp.toBasic)(prev)
304304
u.flatMap(u => w.map(u ++ _))
305305
case (a: InfVar, b: InfVar) if a.uid =/= b.uid => N
306306
case (v: InfVar, _) =>
307307
val p = prev + (v->b)
308-
val k = v.state.lowerBounds.map(lb => disjoint(lb.toBasic.simp.toBasic, b)(p))
308+
val k = v.state.lowerBounds.map(lb => disjoint(lb.simp.toBasic, b)(p))
309309
if k.exists(_.isEmpty) then N
310310
else S((k.flatten.flatten.toSet + Set.empty).map(_ + (v -> b)))
311311
case (_, v: InfVar) => disjoint(v, a)(prev)

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

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
//│ Type: ⊤
55

66

7-
fun andt(x)=x&&true
8-
fun k(f:Nothing->Bool)=1
9-
fun ap(f)=x=>f(x)
7+
fun andt(x) = x && true
8+
fun k(f: Nothing -> Bool) = 1
9+
fun ap(f) = x => f(x)
1010
//│ Type: ⊤
1111

1212
k(andt)
@@ -30,15 +30,28 @@ idIB(true)
3030
idIB(if true then 1 else true)
3131
//│ Type: Bool ∨ Int
3232

33-
x=>
33+
x =>
3434
let y = x+1
3535
idIB(x)
3636
//│ Type: ('x) ->{⊥} ⊥
3737
//│ Where:
3838
//│ 'x <: Int ∨ Bool
3939
//│ 'x <: Int
40-
//│ 'x#Bool ∨ Bool<:'app ∧ ⊥<:'eff}
4140
//│ 'x#Int ∨ Int<:'app ∧ ⊥<:'eff}
41+
//│ 'x#Bool ∨ Bool<:'app ∧ ⊥<:'eff}
42+
43+
(x: Int) =>
44+
let y = x + 1
45+
idIB(x)
46+
//│ Type: (Int) ->{⊥} Int
47+
48+
(x: Bool) =>
49+
idIB(x)
50+
//│ Type: (Bool) ->{⊥} Bool
51+
52+
(x: Bool) =>
53+
idIB(idIB(x))
54+
//│ Type: (Bool) ->{⊥} Bool ∨ Int
4255

4356
fun ap1(f)=f(1)
4457
ap1(idIB)
@@ -48,32 +61,53 @@ ap(idIB)(1)
4861
//│ Type: Int
4962

5063
:todo
51-
x=>idIB(x)
64+
x => idIB(x)
5265
//│ Type: ('x) ->{⊥} ⊥
5366
//│ Where:
5467
//│ 'x <: Int ∨ Bool
68+
//│ 'x#Bool ∨ Bool<:'app ∧ ⊥<:'eff}
5569
//│ 'x#Int ∨ Int<:'app ∧ ⊥<:'eff}
70+
71+
fun forward(x) = idIB(x)
72+
forward
73+
//│ Type: ['x] -> 'x -> ⊥
74+
//│ Where:
75+
//│ 'x <: Int ∨ Bool
5676
//│ 'x#Bool ∨ Bool<:'app ∧ ⊥<:'eff}
77+
//│ 'x#Int ∨ Int<:'app ∧ ⊥<:'eff}
78+
79+
forward(1)
80+
//│ Type: ⊥
81+
82+
forward(true)
83+
//│ Type: ⊥
5784

5885

5986
:todo // BbML
6087
fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
6188
//│ ╔══[ERROR] General type is not allowed here.
62-
//│ ║ l.60: fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
89+
//│ ║ l.87: fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
6390
//│ ╙── ^^^
6491
//│ ╔══[ERROR] General type is not allowed here.
65-
//│ ║ l.60: fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
92+
//│ ║ l.87: fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
6693
//│ ╙── ^^^^
6794
//│ Type: ⊤
6895

6996
:todo // BbML
7097
idIIBB([1, 2])
7198
//│ ╔══[ERROR] Term shape not yet supported by BbML: Tup(List(Fld(‹›,Lit(IntLit(1)),None), Fld(‹›,Lit(IntLit(2)),None)))
72-
//│ ║ l.70: idIIBB([1, 2])
99+
//│ ║ l.97: idIIBB([1, 2])
73100
//│ ╙── ^^^^^^
74101
//│ Type: ⊥
75102

76103

104+
x => if x is
105+
Int then 0
106+
Bool then 0
107+
//│ Type: (((¬Bool ∨ Int) ∨ Bool) ∧ (¬Int ∨ Int)) ->{⊥} Int
108+
109+
110+
77111
class Pair[out A, out B](fst: A, snd: B)
78112
//│ Type: ⊤
79113

@@ -99,7 +133,7 @@ idIIBB(new Pair(1, true))
99133
:todo
100134
fun foo: ["x": Int, "y": Int]
101135
//│ ╔══[ERROR] Invalid type
102-
//│ ║ l.100: fun foo: ["x": Int, "y": Int]
136+
//│ ║ l.134: fun foo: ["x": Int, "y": Int]
103137
//│ ╙── ^^^^^^^^^^^^^^^^^^^^
104138
//│ Type: ⊤
105139

0 commit comments

Comments
 (0)