(define-type Peano (U 'Z (List 'S Peano)))
(: convert : Peano -> Number)
(define (convert n)
(cond [(symbol? n) 0]
[else (add1 (convert (rest n)))]))
n : (List 'S Peano)
n
n : List 'S Peano
Slide 12
Slide 12 text
(: combine :
(U String Symbol) (U String Symbol) -> String)
(define (combine s s*)
(cond [(and (string? s) (string? s*))
(string-append s s*)]
[(string? s)
(string-append s (symbol->string s*))]
[(string? s*)
(string-append (symbol->string s) s*)]
[else
(string-append (symbol->string s)
(symbol->string s*))]))
Slide 13
Slide 13 text
(: combine :
(U String Symbol) (U String Symbol) -> String)
(define (combine s s*)
(cond [(and (string? s) (string? s*))
(string-append s s*)]
[(string? s)
(string-append s (symbol->string s*))]
[(string? s*)
(string-append (symbol->string s) s*)]
[else
(string-append (symbol->string s)
(symbol->string s*))]))
s : (U String Symbol) s* : (U String Symbol)
s
s : U String Symbol
s*
s* : U String Symbol
Slide 14
Slide 14 text
(: combine :
(U String Symbol) (U String Symbol) -> String)
(define (combine s s*)
(cond [(and (string? s) (string? s*))
(string-append s s*)]
[(string? s)
(string-append s (symbol->string s*))]
[(string? s*)
(string-append (symbol->string s) s*)]
[else
(string-append (symbol->string s)
(symbol->string s*))]))
s : String s* : String
s
s : String
s*
s* : String
Slide 15
Slide 15 text
(: combine :
(U String Symbol) (U String Symbol) -> String)
(define (combine s s*)
(cond [(and (string? s) (string? s*))
(string-append s s*)]
[(string? s)
(string-append s (symbol->string s*))]
[(string? s*)
(string-append (symbol->string s) s*)]
[else
(string-append (symbol->string s)
(symbol->string s*))]))
s : String s* : Symbol
s
s : String
s*
s* : Symbol
Slide 16
Slide 16 text
(: combine :
(U String Symbol) (U String Symbol) -> String)
(define (combine s s*)
(cond [(and (string? s) (string? s*))
(string-append s s*)]
[(string? s)
(string-append s (symbol->string s*))]
[(string? s*)
(string-append (symbol->string s) s*)]
[else
(string-append (symbol->string s)
(symbol->string s*))]))
s : Symbol s* : String
s
s : Symbol
s*
s* : String
Slide 17
Slide 17 text
(: combine :
(U String Symbol) (U String Symbol) -> String)
(define (combine s s*)
(cond [(and (string? s) (string? s*))
(string-append s s*)]
[(string? s)
(string-append s (symbol->string s*))]
[(string? s*)
(string-append (symbol->string s) s*)]
[else
(string-append (symbol->string s)
(symbol->string s*))]))
s : Symbol s* : Symbol
s
s : Symbol
s*
s* : Symbol
Local Binding
Γ ⊢ e0
: S ; φ*+
| φ*-
; o
Γ, S@x, #f @ x ⊃ φ*+
⊢ e1
: T ; φ+
| φ-
; o*
Γ ⊢ (let [x e0
] e1
) : T[o/x] ; φ+
| φ-
[o/x] ; o*[o/x]
Slide 56
Slide 56 text
Empirical Evaluation
Estimated usage of two idioms in Racket code base
(600k lines)
• Local binding with or: ~470 uses
• Predicates with Selectors: ~440 uses
Slide 57
Slide 57 text
Prior Work
None of the Examples
Shivers 91, Henglein & Rehof 95, Crary et al 98, ...
Just convert
Aiken et al 94, Wright 94, Flanagan 97,
Komondoor et al 2005
Everything but abstraction
Bierman et al 2010
Slide 58
Slide 58 text
Conclusions
Propositions can relate types and terms
Slide 59
Slide 59 text
Conclusions
Propositions can relate types and terms
Existing programs are a source of type system ideas
Slide 60
Slide 60 text
Thank You
Code and Documentation
http://www.racket-lang.org
[email protected]
Slide 61
Slide 61 text
Thank You
Code and Documentation
http://www.racket-lang.org
[email protected]