Skip to content

Commit 76d0ef2

Browse files
committed
First pass of changes from PR review
1 parent 480a676 commit 76d0ef2

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
@@ -588,23 +588,21 @@
588588
[((Distinction: _ _ S) T)
589589
(cg S T obj)]
590590

591-
;; XXX only barely noticed that cg takes an obj parameter
592-
;; halfway through the rebase
593591
[((Con: S-pre S-post) (Con: T-pre T-post))
594-
(% cset-meet (cg T-pre S-pre obj) (cg S-post T-post obj))]
592+
(% cset-meet (cg T-pre S-pre) (cg S-post T-post))]
595593
[((FlatCon: S-pre S-post) (FlatCon: T-pre T-post))
596-
(% cset-meet (cg T-pre S-pre obj) (cg S-post T-post obj))]
594+
(% cset-meet (cg T-pre S-pre) (cg S-post T-post))]
597595
[((FlatCon: S-pre S-post) (Con: T-pre T-post))
598-
(% cset-meet (cg T-pre S-pre obj) (cg S-post T-post obj))]
596+
(% cset-meet (cg T-pre S-pre) (cg S-post T-post))]
599597
[((and (PredicateProp: (PropSet: (TypeProp: _ S-post) _))
600598
(Fun: (list (Arrow: (list S-pre) _ _ _))))
601599
;; Apparently I can't just have the FlatCon case -- is the inference
602600
;; not aware of the subtyping relation?
603601
(Con*: T-pre T-post))
604-
(% cset-meet (cg T-pre S-pre obj) (cg S-post T-post obj))]
602+
(% cset-meet (cg T-pre S-pre) (cg S-post T-post))]
605603
[((Fun: (list (Arrow: (list S-pre) _ _ _)))
606604
(Con*: T-pre T-post))
607-
(% cset-meet (cg T-pre S-pre obj) (cg S-pre T-post obj))]
605+
(% cset-meet (cg T-pre S-pre) (cg S-pre T-post))]
608606

609607
;; two structs with the same name
610608
;; 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
@@ -708,8 +708,8 @@
708708
(match t2
709709
[(Con: t2-pre t2-post)
710710
(subtype-seq A
711-
(subtype* A t2-pre t1-pre obj)
712-
(subtype* A t1-post t2-post obj))]
711+
(subtype* t2-pre t1-pre)
712+
(subtype* t1-post t2-post))]
713713
[_ (continue<: A t1 t2 obj)])]
714714
[(case: Continuation-Mark-Keyof (Continuation-Mark-Keyof: val1))
715715
(match t2
@@ -814,12 +814,12 @@
814814
(match t2
815815
[(FlatCon: t2-pre t2-post)
816816
(subtype-seq A
817-
(subtype* A t2-pre t1-pre)
818-
(subtype* A t1-post t2-post))]
817+
(subtype* t2-pre t1-pre)
818+
(subtype* t1-post t2-post))]
819819
[(Con: t2-pre t2-post)
820820
(subtype-seq A
821-
(subtype* A t2-pre t1-pre)
822-
(subtype* A t1-post t2-post))]
821+
(subtype* t2-pre t1-pre)
822+
(subtype* t1-post t2-post))]
823823
[_ (continue<: A t1 t2 obj)])]
824824
[(case: Fun (Fun: arrows1))
825825
(match* (t2 arrows1)
@@ -843,12 +843,11 @@
843843
[((or (FlatCon: t2-pre t2-post)
844844
(Con: t2-pre t2-post))
845845
_)
846-
;; XXX hacks
847846
(match t1
848847
[(ConFn*: t1-pre t1-post)
849848
(subtype-seq A
850-
(subtype* A t2-pre t1-pre)
851-
(subtype* A t1-post t2-post))])]
849+
(subtype* t2-pre t1-pre)
850+
(subtype* t1-post t2-post))])]
852851
[(_ _) (continue<: A t1 t2 obj)])]
853852
[(case: Future (Future: elem1))
854853
(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)