Skip to content

Commit 3d4c422

Browse files
author
Ryan Ficklin
committed
Changed treelist-flatten to Any -> TreeListof Any, removed incorrect ToDos regarding Mutable/Immutable TreeLists, added shallow annotations
1 parent 1ab8f95 commit 3d4c422

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

typed-racket-lib/typed-racket/base-env/base-env.rkt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@
13111311
[treelist-cons (-poly (a) (-> (-treelist a) a (-treelist a)))]
13121312
[treelist-delete (-poly (a) (-> (-treelist a) -Index (-treelist a)))]
13131313
[make-treelist (-poly (a) (-> -Nat a (-treelist a)))]
1314-
[treelist-ref (-poly (a) (-> (-treelist a) -Index a))]
1314+
[treelist-ref (-poly (a) (-> (-treelist a) -Index a :T+ #f))]
13151315
[treelist-insert (-poly (a) (-> (-treelist a) -Index a (-treelist a)))]
13161316
[treelist-set (-poly (a) (-> (-treelist a) -Index a (-treelist a)))]
13171317
[treelist-take (-poly (a) (-> (-treelist a) -Index (-treelist a)))]
@@ -1330,13 +1330,13 @@
13301330
[treelist-map (-poly (a b) (-> (-treelist a) (-> a b) (-treelist b)))]
13311331
[treelist-for-each (-poly (a b) (-> (-treelist a) (-> a b) -Void))]
13321332
[treelist-filter (-poly (a) (-> (-> a Univ) (-treelist a) (-treelist a)))]
1333-
[treelist-find (-poly (a) (-> (-treelist a) (-> a Univ) a))]
1333+
[treelist-find (-poly (a) (-> (-treelist a) (-> a Univ) a :T+ #f))]
13341334
[treelist-index-of
13351335
(-poly (a)
13361336
(cl->* ((-treelist a) a . -> . -Index)
13371337
((-treelist a) a (-> a a Univ) . -> . -Index)))]
1338-
[treelist-flatten (-poly (a) (-> a (-treelist a)))] ;; This type isn't any more or less pratical than Univ, but Univ might not be sound
1339-
[treelist-append* (-poly (a) (-> (-treelist (-treelist a)) (-treelist a)))] ;; Same type specificty issue as above
1338+
[treelist-flatten (Univ . -> . (-treelist Univ))]
1339+
[treelist-append* (-poly (a) (-> (-treelist (-treelist a)) (-treelist a)))]
13401340
[treelist-sort
13411341
(-poly
13421342
(a b)

typed-racket-lib/typed-racket/rep/type-rep.rkt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,9 @@
354354
[#:mask mask:set])
355355

356356
;;------
357-
;; Treelist
357+
;; Treelist (Immutable)
358358
;;------
359359

360-
;; TODO separate mutable/immutable treelist types
361360
(def-structural TreeList ([elem #:covariant])
362361
[#:mask mask:treelist])
363362

typed-racket-lib/typed-racket/static-contracts/combinators/derived.rkt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
(define set?/sc (flat/sc #'(lambda (x) (or (set? x) (set-mutable? x) (set-weak? x)))))
3232
(define empty-set/sc (and/sc set?/sc (flat/sc #'set-empty?)))
3333

34-
;; TODO: Split TreeList into Mutable and Immutable
3534
(define treelist?/sc (flat/sc #'treelist?))
3635
(define empty-treelist/sc (and/sc treelist?/sc (flat/sc #'treelist-empty?)))
3736

typed-racket-test/unit-tests/typecheck-tests.rkt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,9 +1951,8 @@
19511951
(tc-e (treelist-for-each (treelist "a" "b") (λ (x) x)) -Void)
19521952
(tc-e (treelist-find (treelist "a" "b") (λ (x) (if (equal? x "a") #t #f))) -String)
19531953
(tc-e (treelist-filter even? (treelist 1 2 3 4 5)) (-treelist -PosByte))
1954-
(tc-e (treelist-flatten (treelist (treelist (treelist (treelist "a")))))
1955-
(-treelist (-treelist (-treelist (-treelist (-treelist -String)))))) ;;FIXME: this type is unpleasant
1956-
(tc-e (treelist-flatten "a") (-treelist -String))
1954+
(tc-e (treelist-flatten (treelist (treelist (treelist (treelist "a"))))) (-treelist Univ))
1955+
(tc-e (treelist-flatten "a") (-treelist Univ))
19571956
(tc-e (treelist-append* (treelist (treelist "a" "b") (treelist "c" (treelist "d") "e") (treelist))) (-treelist Univ))
19581957
(tc-e (treelist-index-of (treelist "a" "b" "c") "b") -Index)
19591958
(tc-e (treelist-index-of (treelist "a" "b" "c") "b" equal?) -Index)

0 commit comments

Comments
 (0)