Last active
December 14, 2015 01:49
-
-
Save samth/5009113 to your computer and use it in GitHub Desktop.
Restricting the keywords
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang typed/racket | |
(: f (case-> | |
(Integer [#:application Integer] [#:context Nothing] -> (List Integer Integer)) | |
(Integer [#:context Integer] [#:application Nothing] -> (List Integer Integer)))) | |
(define (f x #:application [a 0] #:context [c 0]) | |
(list a c)) | |
(f 1) | |
(f 1 #:application 5) | |
(f 1 #:context 5) | |
(f 1 #:application 5 #:context 5) ;; doesn't typecheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang typed/racket | |
(: f (Integer [#:application Integer] [#:context Integer] | |
-> (List Integer Integer))) | |
(define (f x #:application [#{a : (U Integer #f)} #f] #:context [#{c : (U Integer #f)} #f]) | |
(cond [(and a c) (error "too many keywords")] | |
[a (list a 0)] | |
[c (list 0 c)] | |
[else (list 0 0)])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment