cur/stdlib/maybe.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

20 lines
542 B
Racket

#lang s-exp "../redex-curnel.rkt"
(require "sugar.rkt")
(provide maybe none some)
(data maybe : (forall (A : Type) Type)
(none : (forall (A : Type) (maybe A)))
(some : (forall* (A : Type) (a : A) (maybe A))))
(module+ test
(require rackunit "bool.rkt")
;; TODO: Dependent pattern matching doesn't work yet
(check-equal?
(case* maybe (some bool btrue)
(lambda (x : (maybe bool)) bool)
[(none (A : Type)) with-IH ()
bfalse]
[(some (A : Type) (x : A)) with-IH ()
(if x btrue bfalse)])
btrue))