cur/stdlib/bool.rkt
William J. Bowman fae24ab496
Styles tweaks
* Types now start with a Capital letter, because.
* Boolean expression no longer start with the letter b.
2015-09-22 23:32:02 -04:00

23 lines
531 B
Racket

#lang s-exp "../cur.rkt"
(require "sugar.rkt")
(provide Bool true false if not and or)
(data Bool : Type
(true : Bool)
(false : 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))])
(quasisyntax/loc syn (elim Bool t #,M s f)))]))
(define (not (x : Bool)) (if x false true))
(module+ test
(require rackunit)
(check-equal? (not true) false)
(check-equal? (not false) true))