Last active
December 18, 2015 00:59
-
-
Save takikawa/5701053 to your computer and use it in GitHub Desktop.
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 | |
(define-type (Even A) (U Null (Pairof A (Odd A)))) | |
(define-type (Odd A) (Pairof A (Even A))) | |
(: even-lst (Even Integer)) | |
(define even-lst '(1 2 3 4)) | |
(: odd-lst (Odd Integer)) | |
(define odd-lst '(1 2 3)) | |
(: even->odd (All (A) (A (Even A) -> (Odd A)))) | |
(define (even->odd elem lst) | |
(cons elem lst)) | |
(provide even->odd Even Odd | |
even-lst odd-lst) |
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
-> (even->odd 1 '(1)) | |
; even->odd: contract violation | |
; expected: pair? | |
; given: '() | |
; in: the cdr of | |
; a disjunct of | |
; the 2nd argument of | |
; (-> | |
; any/c | |
; (recursive-contract | |
; (or/c | |
; null? | |
; (cons/c | |
; any/c | |
; (recursive-contract | |
; (cons/c ctc27 (Even122 ctc27)) | |
; #:chaperone))) | |
; #:chaperone) | |
; (recursive-contract | |
; (cons/c | |
; any/c | |
; (recursive-contract | |
; (or/c | |
; null? | |
; (cons/c ctc35 (Odd230 ctc35))) | |
; #:chaperone)) | |
; #:chaperone)) | |
; contract from: | |
; <collects>/tests/typed-racket/even-odd.rkt | |
; blaming: top-level | |
; at: <collects>/tests/typed-racket/even-odd.rkt:27.9 | |
; [,bt for context] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment