Skip to content

Commit 7afbe26

Browse files
committed
implement unions of box types
1 parent b9139a5 commit 7afbe26

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

typed-racket-lib/typed-racket/types/union.rkt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
[(_ _) #:when (currently-subtyping?) (cons a b)]
3838
[((? (λ _ (subtype a b*))) _) b]
3939
[((? (λ _ (subtype b* a))) _) (list a)]
40+
;; the union of two box types is a box type where the write type has to satisfy both write types,
41+
;; and the read type can satisfy either of the two read types
42+
[((Box: a-w a-r) (list-no-order (Box: b-w b-r) bs ...))
43+
(define w
44+
(cond [(subtype a-w b-w) a-w]
45+
[(subtype b-w a-w) b-w]
46+
[else -Bottom]))
47+
(cons (make-Box w (Un a-r b-r)) bs)]
4048
[(_ _) (cons a (filter-not (λ (b-elem) (subtype b-elem a)) b))]))
4149

4250
;; Type -> List[Type]

0 commit comments

Comments
 (0)