typed-racket/typed-racket-test/succeed/struct-update.rkt
2015-01-14 15:32:34 +05:30

17 lines
392 B
Racket

#lang typed/racket/base
;; ensures updates to a struct's field
;; which results in Bottom
;; properly propogates Bottom up
(define-type ABC (U 'a 'b 'c))
(define-struct ABCWrapper ([abc : ABC]))
(: abc-123-let (ABCWrapper -> (U 1 2 3)))
(define (abc-123-let wrapper)
(let ([abc (ABCWrapper-abc wrapper)])
(cond
[(eq? abc 'a) 1]
[(eq? abc 'b) 2]
[(eq? abc 'c) 3])))