From cbd0addb8e150f5fbca2a777095419aa7ce5f29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Fri, 5 May 2017 03:34:17 +0200 Subject: [PATCH] =?UTF-8?q?Small=20improvements=20to=20contract=E2=86=92ty?= =?UTF-8?q?pe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts-to-types.rkt | 3 +++ scribblings/contracts-to-types.scrbl | 3 ++- test/test-contracts-to-types.rkt | 13 ++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/contracts-to-types.rkt b/contracts-to-types.rkt index 053fb70..795149f 100644 --- a/contracts-to-types.rkt +++ b/contracts-to-types.rkt @@ -36,6 +36,9 @@ [(_ {~literal c:boolean?}) #'Boolean] [(_ {~literal c:bytes?}) #'Bytes] [(_ {~literal c:void?}) #'Void] + [(_ {~literal c:null?}) #'Null] + [(_ {~literal c:empty?}) #'Null] + [(_ {~literal c:list?}) #'(Listof Any)] [(_ {~literal c:exact-nonnegative-integer?}) #'Exact-Nonnegative-Integer] [(_ {~literal c:exact-positive-integer?}) #'Exact-Positive-Integer] [(_ ({~literal c:syntax/c} τ)) #'(Syntaxof (c→t τ))] diff --git a/scribblings/contracts-to-types.scrbl b/scribblings/contracts-to-types.scrbl index e198ed5..195aafb 100644 --- a/scribblings/contracts-to-types.scrbl +++ b/scribblings/contracts-to-types.scrbl @@ -16,7 +16,8 @@ @racket[listof], @racket[list/c], @racket[*list/c], @racket[vectorof], @racket[vector/c], @racket[cons/c], @racket[number?], @racket[integer?], @racket[string?], @racket[symbol?], @racket[char?], @racket[boolean?], - @racket[bytes?], @racket[void?], @racket[exact-nonnegative-integer?], + @racket[bytes?], @racket[void?], @racket[null?], @racket[empty?], + @racket[list?], @racket[exact-nonnegative-integer?], @racket[exact-positive-integer?], @racket[syntax/c], @racket[parameter/c], @racket[promise/c], @racket[suggest/c], @racket[flat-rec-contract], some uses of @racket[->] and @racket[->*], @racket['quoted-datum], diff --git a/test/test-contracts-to-types.rkt b/test/test-contracts-to-types.rkt index 90a8c89..f49f4ff 100644 --- a/test/test-contracts-to-types.rkt +++ b/test/test-contracts-to-types.rkt @@ -42,4 +42,15 @@ '(->* (Integer Boolean) () Symbol)) (check-written=? (:contract→type (flat-rec-contract W (cons/c W W) number? string?)) - '(Rec W (U (Pairof W W) Number String))) \ No newline at end of file + '(Rec W (U (Pairof W W) Number String))) +(check-written=? (:contract→type + (flat-rec-contract W + (cons/c (flat-rec-contract R + (cons/c W R) + null?) + W) + number? + string?)) + '(Rec W (U (Pairof '(Rec R (U (Pairof R W) Null)) W) + Number + String))) \ No newline at end of file