From 9bb66a9c58f0a15b97ce9e8f4d24bc970913ad10 Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Fri, 10 Jan 2014 09:16:17 -0800 Subject: [PATCH] Remove terminal contract generic interface. --- .../static-contracts/combinators/simple.rkt | 5 ++--- .../static-contracts/optimize.rkt | 2 +- .../static-contracts/structures.rkt | 19 +++++++------------ .../static-contracts/terminal.rkt | 5 ++--- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/simple.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/simple.rkt index 4e9f488975..76a428fbe8 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/simple.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/simple.rkt @@ -36,9 +36,8 @@ [(define (sc-map v f) v) (define (sc-traverse v f) (void)) (define (sc->contract v f) (simple-contract-syntax v)) - (define (sc->constraints v f) (simple-contract-restrict (simple-contract-kind v)))] - #:methods gen:terminal-sc - [(define (terminal-sc-kind v) (simple-contract-kind v))] + (define (sc->constraints v f) (simple-contract-restrict (simple-contract-kind v))) + (define (sc-terminal-kind v) (simple-contract-kind v))] #:methods gen:custom-write [(define write-proc simple-contract-write-proc)]) (define (flat/sc ctc [name #f]) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/optimize.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/optimize.rkt index ce5b4ea87a..16b20040a6 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/optimize.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/optimize.rkt @@ -82,7 +82,7 @@ [(arr/sc: args rest (list (any/sc:) ...)) (arr/sc args rest #f)] [(none/sc:) any/sc] - [(app terminal-sc-kind 'flat) any/sc] + [(app sc-terminal-kind 'flat) any/sc] [else sc])) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/structures.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/structures.rkt index 6bcf8fe8e6..645348703d 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/structures.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/structures.rkt @@ -18,14 +18,13 @@ [sc-traverse (static-contract? (static-contract? variance/c . -> . any/c) . -> . void?)] [sc->contract (static-contract? (static-contract? . -> . syntax?) . -> . syntax?)] [sc->constraints (static-contract? (static-contract? . -> . contract-restrict?) . -> . contract-restrict?)] - [terminal-sc-kind (static-contract? . -> . (or/c #f contract-kind?))] + [sc-terminal-kind (static-contract? . -> . (or/c #f contract-kind?))] [sc? predicate/c] ) prop:combinator-name - gen:sc - gen:terminal-sc) + gen:sc) (define variance/c (or/c 'covariant 'contravariant 'invariant)) @@ -109,17 +108,13 @@ ;; sc->constraints: static-contract? (static-contract? -> constraint-set?) -> constraint-set? ;; Takes a static contract and computes the constraint set for a static contract. ;; The function argument should be used for sub parts of the static contract. - [sc->constraints sc f]) - -;; Functionality that terminal static contracts should support -;; Terminal static contracts are ones without any sub static contracts -(define-generics terminal-sc - ;; terminal-sc-kind: terminal-static-contract? -> (or/c #f contract-kind?) + [sc->constraints sc f] + ;; sc-terminal-kind: static-contract? -> (or/c #f contract-kind?) ;; Returns the kind of contract that this represents ;; Returns #f if it is not a terminal contract - [terminal-sc-kind terminal-sc] - #:defaults ([(λ (v) #t) - (define (terminal-sc-kind v) #f)])) + [sc-terminal-kind sc] + #:fallbacks + [(define (sc-terminal-kind v) #f)]) ;; Super struct of static contracts (struct static-contract () diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/terminal.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/terminal.rkt index 66969c6a52..ce224d5bf9 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/terminal.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/terminal.rkt @@ -41,6 +41,5 @@ (define (sc->contract v unused-f) (match-define (name args ...) v) body) - (define (sc->constraints v f) (simple-contract-restrict 'kind.sym))] - #:methods gen:terminal-sc - [(define (terminal-sc-kind v) 'kind.sym)])])) + (define (sc->constraints v f) (simple-contract-restrict 'kind.sym)) + (define (sc-terminal-kind v) 'kind.sym)])]))