typed-racket/typed-racket-test/succeed/units-no-sigs.rkt
Daniel Feltey 2e0cc095c7 Initial support for typed units in typed racket.
Most unit forms are supported, including most of the "infer" forms that
infer imports/exports/linkages from the current context.

Notably, none of the structural linking forms for units are supported, and
`define-unit-binding` is also currently unsupported.
2015-09-10 16:32:11 -05:00

34 lines
935 B
Racket

#lang typed/racket
(define-signature yz-sig ([y : Integer] [z : Integer]))
(let ((y 1)
(z 10))
(define u (unit (import) (export yz-sig)
(define y 2)
(define z 3)))
(define u1 (unit (import) (export)
y))
(define u2 (unit (import (only yz-sig z)) (export)
y))
(define u3 (unit (import (except yz-sig y)) (export)
y))
(define u4 (unit (import (prefix s: yz-sig)) (export)
y))
(define u5 (unit (import (rename yz-sig (r y))) (export)
y))
(define u6 (unit (import yz-sig) (export)
y))
(: l (-> (Unit (import yz-sig) (export) Integer) Integer))
(define (l x)
(invoke-unit
(compound-unit (import) (export)
(link (((YZ : yz-sig)) u)
(() x YZ)))))
(invoke-unit u1)
(l u2)
(l u3)
(l u4)
(l u5)
(l u6))