typed-racket/typed-racket-test/succeed/macro-in-unit.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

28 lines
759 B
Racket

#lang typed/racket
(require (for-syntax syntax/parse))
(define-signature x^ ([x : Integer] [y : String] [z : (-> Symbol)]))
(unit (import)
(export x^)
(define-syntax (my-define stx)
(syntax-parse stx
[(_ name:id expr:exact-integer)
#'(begin
(: name Integer)
(define name expr))]
[(_ name:id expr:str)
#'(begin
(: name String)
(define name expr))]
[(_ name:id #:with-type type expr)
#'(begin
(: name type)
(define name expr))]))
(my-define x 17)
(my-define a "hello")
(my-define y "a string")
(my-define z #:with-type (-> Symbol) (λ () (string->symbol y))))