PasteRack.org
Paste # 145
2019-07-05 14:37:36

Fork as a new paste.

Paste viewed 521 times.


Embed:

  1. #lang typed/racket
  2. (require typed/racket/unsafe)
  3.  
  4. (module untyped racket
  5.   (provide maybe-car)
  6.   (define (maybe-car x)
  7.     (cond
  8.       [(pair? x) (car x)]
  9.       [else x])))
  10.  
  11. (unsafe-require/typed
  12.  'untyped
  13.  [maybe-car (All (a b) (case->
  14.                         (-> (Pairof a b) a)
  15.                         (-> a a)))])
  16.  
  17. (maybe-car (cons 'foo 'bar))
  18. (maybe-car 94)

=>

eval:2:0: ?: access disallowed by code inspector to

protected transformer

  from module: "/home/pasterack/racket73/share/pkgs/typed-ra

cket-lib/typed/racket/unsafe.rkt"

  at: unsafe-require/typed

eval:3:0: Type Checker: missing type for top-level

identifier;

 either undefined or missing a type annotation

  identifier: maybe-car

  in: bar

eval:4:0: Type Checker: missing type for top-level

identifier;

 either undefined or missing a type annotation

  identifier: maybe-car

  in: 94