phc-toolkit/cond-let.rkt
2017-04-27 23:38:55 +02:00

19 lines
601 B
Racket

#lang typed/racket
(require "typed-untyped.rkt")
(define-typed/untyped-modules #:no-test
(provide cond-let)
(require (for-syntax syntax/parse
phc-toolkit/untyped/aliases))
(define-syntax (cond-let stx)
(syntax-parse stx
[(_)
#'(typecheck-fail #,stx)]
[(_ #:let bindings:expr clause )
#'(let bindings (cond-let clause ))]
[(_ [condition:expr (~seq #:else-let binding ) . body] clause )
#'(if condition
(begin . body)
(let (binding )
(cond-let clause )))])))