Skip to content

Commit

Permalink
ported the contracts in srfi/14 to racket/contract
Browse files Browse the repository at this point in the history
  • Loading branch information
rfindler committed May 8, 2012
1 parent 745607a commit 646403e
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions collects/srfi/14/char-set.rkt
@@ -1,12 +1,11 @@
;; Since Matthew implemented this module, tests are in
;; collects/tests/mzscheme/char-set.rkt.
;; collects/tests/racket/char-set.rktl.
;; Since Mike Sperber looked carefully at this module,
;; the code and tests are a lot better than they would be.

(module char-set mzscheme
(require mzlib/integer-set
(all-except mzlib/contract union)
(rename mzlib/contract union/c union))
racket/contract)

;; Data defn ----------------------------------------

Expand Down Expand Up @@ -375,49 +374,46 @@

;; Contracts and provides ----------------------------------------

(define-syntax (char-sets0/c stx)
#'(case-> (char-set? char-set? . -> . any)
(() (listof char-set?) . ->* . any)))
(define char-sets0/c
(->* () #:rest (listof char-set?) any))

(define-syntax (char-sets/c stx)
#'(case-> (char-set? char-set? . -> . any)
((char-set?) (listof char-set?) . ->* . any)))
(define char-sets/c
(->* (char-set?) #:rest (listof char-set?) any))

(define-syntax (char-sets+/c stx)
#'(case-> (char-set? char-set? . -> . any)
((char-set? char-set?) (listof char-set?) . ->* . any)))
(define char-sets+/c
(->* (char-set? char-set?) #:rest (listof char-set?) any))

(define ei/c (and/c number? integer? exact?))

(define-syntax (char-set-char/c stx)
#'((char-set?) (listof char?) . ->* . (char-set?)))
(define char-set-char/c
(->* (char-set?) #:rest (listof char?) char-set?))

(provide
char-set?)
(provide/contract
[char-set= char-sets0/c]
[char-set<= char-sets0/c]
[char-set-hash ((char-set?) (integer?) . opt-> . integer?)]
[char-set-hash (->* (char-set?) (integer?) integer?)]
[char-set-cursor (char-set? . -> . any)]
[char-set-ref (char-set? any/c . -> . char?)]
[char-set-cursor-next (char-set? any/c . -> . any)]
[end-of-char-set? (any/c . -> . boolean?)]
[char-set-fold ((char? any/c . -> . any) any/c char-set? . -> . any)]
[char-set-unfold (((any/c . -> . any) (any/c . -> . char?) (any/c . -> . any) any/c) (char-set?) . opt-> . char-set?)]
[char-set-unfold (->* ((any/c . -> . any) (any/c . -> . char?) (any/c . -> . any) any/c) (char-set?) char-set?)]
[char-set-unfold! ((any/c . -> . any) (any/c . -> . char?) (any/c . -> . any) any/c char-set? . -> . char-set?)]
[char-set-for-each ((char? . -> . any) char-set? . -> . any)]
[char-set-map ((char? . -> . any) char-set? . -> . char-set?)]
[char-set-copy (char-set? . -> . char-set?)]
[rename mk-char-set char-set (() (listof char?) . ->* . (char-set?))]
[list->char-set (((listof char?)) (char-set?) . opt-> . char-set?)]
[rename mk-char-set char-set (->* () #:rest (listof char?) char-set?)]
[list->char-set (->* ((listof char?)) (char-set?) char-set?)]
[list->char-set! ((listof char?) char-set? . -> . char-set?)]
[string->char-set ((string?) (char-set?) . opt-> . char-set?)]
[string->char-set (->* (string?) (char-set?) char-set?)]
[string->char-set! (string? char-set? . -> . char-set?)]
[char-set-filter (((char? . -> . any) char-set?) (char-set?) . opt-> . char-set?)]
[char-set-filter (->* ((char? . -> . any) char-set?) (char-set?) char-set?)]
[char-set-filter! ((char? . -> . any) char-set? char-set? . -> . char-set?)]
[ucs-range->char-set ((ei/c ei/c) (any/c char-set?) . opt-> . char-set?)]
[ucs-range->char-set (->* (ei/c ei/c) (any/c char-set?) char-set?)]
[ucs-range->char-set! (ei/c ei/c any/c char-set? . -> . char-set?)]
[->char-set ((union/c string? char? char-set?) . -> . char-set?)]
[->char-set ((or/c string? char? char-set?) . -> . char-set?)]
[char-set->list (char-set? . -> . any)]
[char-set->string (char-set? . -> . any)]
[char-set-size (char-set? . -> . any)]
Expand Down

0 comments on commit 646403e

Please sign in to comment.