typed-racket/typed-racket-test/succeed/intersection1.rkt
Andrew Kent b4a4c174e4 initial intersection types addition
Adds intersection types as a better way to handle the the case
when restrict cannot structurally intersect two types (e.g. when
you learn within a polymorphic function a variable x of type A
is also an Integer, but we dont know how A relates to Integer).
This allows for non-lossy refinements of type info while typechecking.
2016-05-20 11:34:04 -04:00

20 lines
284 B
Racket

#lang racket/base
(module a typed/racket
(provide num-id)
(: num-id ( (A) (-> ( Number A) ( Number A))))
(define (num-id x) x))
(require 'a)
(let ()
(num-id 42)
(void))
(with-handlers ([exn:fail:contract?
(λ (ex) (void))])
(num-id "42"))