cur/stdlib/bool.rkt
William J. Bowman c4f0f723f5 Dynamic semantics for elim
elim now runs. Parts of the stdlib have been converted to use elim, but
it's complicated to program with. Need to implement case and fix in
terms of elim, I think.
2015-03-27 21:16:20 -04:00

21 lines
504 B
Racket

#lang s-exp "../redex-curnel.rkt"
(provide bool btrue bfalse if bnot)
(data bool : Type
(btrue : bool)
(bfalse : bool))
(define-syntax (if syn)
(syntax-case syn ()
[(_ t s f)
;; Compute the motive
(let ([M #`(lambda (x : #,(type-infer/syn #'t))
#,(type-infer/syn #'s))])
#`(elim bool t #,M s f))]))
(define (bnot (x : bool)) (if x bfalse btrue))
(module+ test
(require rackunit)
(check-equal? (bnot btrue) bfalse)
(check-equal? (bnot bfalse) btrue))