Skip to content

Commit ab2a68a

Browse files
committed
Changes from meeting
1 parent aa956a7 commit ab2a68a

File tree

2 files changed

+38
-18
lines changed

2 files changed

+38
-18
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: 31 additions & 11 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
4255

4356
fun ap1(f)=f(1)
4457
ap1(idIB)
@@ -48,32 +61,39 @@ 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
55-
//│ 'x#Int ∨ Int<:'app ∧ ⊥<:'eff}
5668
//│ 'x#Bool ∨ Bool<:'app ∧ ⊥<:'eff}
69+
//│ 'x#Int ∨ Int<:'app ∧ ⊥<:'eff}
5770

5871

5972
:todo // BbML
6073
fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
6174
//│ ╔══[ERROR] General type is not allowed here.
62-
//│ ║ l.60: fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
75+
//│ ║ l.73: fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
6376
//│ ╙── ^^^
6477
//│ ╔══[ERROR] General type is not allowed here.
65-
//│ ║ l.60: fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
78+
//│ ║ l.73: fun idIIBB: ([Int, Int] -> Int) & ([Bool, Bool] -> Bool)
6679
//│ ╙── ^^^^
6780
//│ Type: ⊤
6881

6982
:todo // BbML
7083
idIIBB([1, 2])
7184
//│ ╔══[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])
85+
//│ ║ l.83: idIIBB([1, 2])
7386
//│ ╙── ^^^^^^
7487
//│ Type: ⊥
7588

7689

90+
x => if x is
91+
Int then 0
92+
Bool then 0
93+
//│ Type: (((¬Bool ∨ Int) ∨ Bool) ∧ (¬Int ∨ Int)) ->{⊥} Int
94+
95+
96+
7797
class Pair[out A, out B](fst: A, snd: B)
7898
//│ Type: ⊤
7999

@@ -99,7 +119,7 @@ idIIBB(new Pair(1, true))
99119
:todo
100120
fun foo: ["x": Int, "y": Int]
101121
//│ ╔══[ERROR] Invalid type
102-
//│ ║ l.100: fun foo: ["x": Int, "y": Int]
122+
//│ ║ l.120: fun foo: ["x": Int, "y": Int]
103123
//│ ╙── ^^^^^^^^^^^^^^^^^^^^
104124
//│ Type: ⊤
105125

0 commit comments

Comments
 (0)