Skip to content

Commit 2d3e8e3

Browse files
committed
First pass of changes from PR review
1 parent 04112d7 commit 2d3e8e3

File tree

9 files changed

+26
-36
lines changed

9 files changed

+26
-36
lines changed

typed-racket-doc/typed-racket/scribblings/reference/typed-contracts.scrbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ currently supported in Typed Racket.
7777
@defthing[natural-number/c (FlatCon Any Natural)]
7878
@defproc[(string-len/c [len Real])
7979
(FlatCon Any String)]
80+
@defthing[false/c (Con Any False)]
8081
@defthing[printable/c (FlatCon Any Any)]
8182
@defproc[(listof [c (Con a b)])
8283
(Con (Listof a) (Listof b))]

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
;; syntax objects for surface-level types (e.g. Real instead of -Real)
2222
(base-env base-types base-types-extra)
2323
(prefix-in untyped: racket/contract/base))
24-
(provide (except-out (all-defined-out)
25-
define-contract)
26-
;; TODO: since we don't support all of the p/c-item forms (exists,
27-
;; struct, etc.), we really should provide our own versions of these
28-
;; two forms that give good "x is unsupported" messages
24+
(provide ;; TODO: we don't support all of the p/c-item forms
25+
;; (exists, struct, etc.), we really should provide our own
26+
;; versions of provide/contract and contract-out that give
27+
;; good "x is unsupported" messages
2928
(rename-out [untyped:provide/contract provide/contract]
3029
[untyped:contract-out contract-out]
3130
[untyped:contract contract]))
@@ -37,6 +36,7 @@
3736
(syntax-parse stx
3837
[(_ :def ...)
3938
#'(begin
39+
(provide ctc ...)
4040
(define-syntax ctc
4141
(make-variable-like-transformer
4242
#`(#,(ignore-some-expr-property #'#%expression #'ty)
@@ -62,9 +62,7 @@
6262
(-> Integer Integer (FlatCon Any Integer)))]
6363
[natural-number/c (FlatCon Any Natural)]
6464
[string-len/c (-> Real (FlatCon Any String))]
65-
;; Because we can use FlatCon in function position and because false/c = #f,
66-
;; giving it the type below is not sound
67-
;; [false/c (FlatCon Any False)]
65+
[false/c (Con Any False)]
6866
[printable/c (FlatCon Any Any)]
6967
;; one-of/c
7068
;; vectorof

typed-racket-lib/typed-racket/infer/infer-unit.rkt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -617,23 +617,21 @@
617617
[((Distinction: _ _ S) T)
618618
(cg S T obj)]
619619

620-
;; XXX only barely noticed that cg takes an obj parameter
621-
;; halfway through the rebase
622620
[((Con: S-pre S-post) (Con: T-pre T-post))
623-
(% cset-meet (cg T-pre S-pre obj) (cg S-post T-post obj))]
621+
(% cset-meet (cg T-pre S-pre) (cg S-post T-post))]
624622
[((FlatCon: S-pre S-post) (FlatCon: T-pre T-post))
625-
(% cset-meet (cg T-pre S-pre obj) (cg S-post T-post obj))]
623+
(% cset-meet (cg T-pre S-pre) (cg S-post T-post))]
626624
[((FlatCon: S-pre S-post) (Con: T-pre T-post))
627-
(% cset-meet (cg T-pre S-pre obj) (cg S-post T-post obj))]
625+
(% cset-meet (cg T-pre S-pre) (cg S-post T-post))]
628626
[((and (PredicateProp: (PropSet: (TypeProp: _ S-post) _))
629627
(Fun: (list (Arrow: (list S-pre) _ _ _))))
630628
;; Apparently I can't just have the FlatCon case -- is the inference
631629
;; not aware of the subtyping relation?
632630
(Con*: T-pre T-post))
633-
(% cset-meet (cg T-pre S-pre obj) (cg S-post T-post obj))]
631+
(% cset-meet (cg T-pre S-pre) (cg S-post T-post))]
634632
[((Fun: (list (Arrow: (list S-pre) _ _ _)))
635633
(Con*: T-pre T-post))
636-
(% cset-meet (cg T-pre S-pre obj) (cg S-pre T-post obj))]
634+
(% cset-meet (cg T-pre S-pre) (cg S-pre T-post))]
637635

638636
;; two structs with the same name
639637
;; just check pairwise on the fields

typed-racket-lib/typed-racket/infer/infer.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
define-values/invoke-unit/infer link
77
only))
88

9-
(provide-signature-elements intersect^ infer^ (only constraints^ meet join))
9+
(provide-signature-elements intersect^ infer^)
1010

1111
(define-values/invoke-unit/infer
1212
(link infer@ constraints@ dmap@ intersect@))

typed-racket-lib/typed-racket/types/pairwise-intersect.rkt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
(provide pairwise-intersect)
1515

16-
(define (pairwise-intersect/arr s t)
16+
(define (pairwise-intersect/arrow s t)
1717
(match* (s t)
1818
[((Arrow: s-dom s-rest s-kws s-rng)
1919
(Arrow: t-dom t-rest t-kws t-rng))
@@ -84,7 +84,7 @@
8484
[(u (Univ:)) u]
8585
[((Fun: arr1s) (Fun: arr2s))
8686
#:when (= (length arr1s) (length arr2s))
87-
(make-Fun (map pairwise-intersect/arr arr1s arr2s))]
87+
(make-Fun (map pairwise-intersect/arrow arr1s arr2s))]
8888
[((Result: ss pset-s o1) (Result: ts pset-t o2))
8989
(make-Result (pairwise-intersect ss ts)
9090
(pairwise-intersect/prop-set pset-s pset-t)

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,8 @@
706706
(match t2
707707
[(Con: t2-pre t2-post)
708708
(subtype-seq A
709-
(subtype* A t2-pre t1-pre obj)
710-
(subtype* A t1-post t2-post obj))]
709+
(subtype* t2-pre t1-pre)
710+
(subtype* t1-post t2-post))]
711711
[_ (continue<: A t1 t2 obj)])]
712712
[(case: Continuation-Mark-Keyof (Continuation-Mark-Keyof: val1))
713713
(match t2
@@ -813,12 +813,12 @@
813813
(match t2
814814
[(FlatCon: t2-pre t2-post)
815815
(subtype-seq A
816-
(subtype* A t2-pre t1-pre)
817-
(subtype* A t1-post t2-post))]
816+
(subtype* t2-pre t1-pre)
817+
(subtype* t1-post t2-post))]
818818
[(Con: t2-pre t2-post)
819819
(subtype-seq A
820-
(subtype* A t2-pre t1-pre)
821-
(subtype* A t1-post t2-post))]
820+
(subtype* t2-pre t1-pre)
821+
(subtype* t1-post t2-post))]
822822
[_ (continue<: A t1 t2 obj)])]
823823
[(case: Fun (Fun: arrows1))
824824
(match* (t2 arrows1)
@@ -842,12 +842,11 @@
842842
[((or (FlatCon: t2-pre t2-post)
843843
(Con: t2-pre t2-post))
844844
_)
845-
;; XXX hacks
846845
(match t1
847846
[(ConFn*: t1-pre t1-post)
848847
(subtype-seq A
849-
(subtype* A t2-pre t1-pre)
850-
(subtype* A t1-post t2-post))])]
848+
(subtype* t2-pre t1-pre)
849+
(subtype* t1-post t2-post))])]
851850
[(_ _) (continue<: A t1 t2 obj)])]
852851
[(case: Future (Future: elem1))
853852
(match t2

typed-racket-lib/typed-racket/utils/contract-utils.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
;; Assumes ty has non-#f confn-type-components
6363
(define (confn-out ty) (cadr (confn-type-components ty)))
6464
;; confn-type-components : Type? -> #f or ConFnInfo
65-
;; Note: only gets components for functions with a single unary arr
65+
;; Note: only gets components for functions with a single unary arrow
6666
(define (confn-type-components ty)
6767
;; TODO: find all unary arities and union their inputs/meet their outputs
6868
(match ty
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
#lang typed-racket/minimal
22
(require racket/require
3-
;; (subtract-in racket/contract
4-
;; typed-racket/base-env/contract-prims)
53
typed-racket/base-env/contract-prims)
64

7-
(provide (all-from-out typed-racket/base-env/contract-prims)
8-
;; (except-out (all-from-out racket/contract) case-> ->* ->)
9-
;; (rename-out [case-> case->/c]
10-
;; [->* ->*/c])
11-
)
5+
(provide (all-from-out typed-racket/base-env/contract-prims))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
[tc-e (integer-in 17 71) (-FlatCon Univ -PosInt)]
4545
[tc-e (string-len/c 3) (-FlatCon Univ -String)]
4646
[tc-e natural-number/c (-FlatCon Univ -Nat)]
47-
[tc-e false/c (-FlatCon Univ -False)]
47+
[tc-e false/c (-Con Univ -False)]
4848
[tc-e printable/c (-FlatCon Univ Univ)]
4949
[tc-e (listof (>/c 5)) (-Con (-lst Univ) (-lst -Real))]
5050
[tc-e (listof string?) (-Con (-lst Univ) (-lst -String))]

0 commit comments

Comments
 (0)