Skip to content

Instantly share code, notes, and snippets.

@philnguyen
Created February 15, 2019 16:06
Show Gist options
  • Save philnguyen/2c98df684f74c0eb2e2a02922155bc27 to your computer and use it in GitHub Desktop.
Save philnguyen/2c98df684f74c0eb2e2a02922155bc27 to your computer and use it in GitHub Desktop.
#lang racket/base
(module typed typed/racket/base
(provide double)
(define-type Increasing (([n : Natural]) . → . (Refine [a : Natural] (> a n))))
(: double : Increasing → Increasing)
;; Modular type-checking of this module cannot eliminate:
;; - `(Refine [a : Natural] (> a n))` in `f`'s range
;; - `Natural` in `n`
(define ((double f) n) (f (f n))))
(module untyped racket/base
(require (submod ".." 'typed))
(provide/contract [add2 (integer? . -> . integer?)])
(define add2 (double add1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment