diff --git a/beautiful-racket-lib/br/eopl.rkt b/beautiful-racket-lib/br/eopl.rkt index 5062b6c..03bfc03 100644 --- a/beautiful-racket-lib/br/eopl.rkt +++ b/beautiful-racket-lib/br/eopl.rkt @@ -28,15 +28,15 @@ (values rator rand)))) -(define #'(define-datatype - ( [ ] ...) ...) +(define #'(define-datatype _base-type _base-type-predicate? + (_subtype [_field _field-predicate?] ...) ...) #'(begin - (struct () #:transparent #:mutable) - (struct ( ...) #:transparent #:mutable - #:guard (λ( ... name) - (unless ( ) - (error name (format "arg ~a is not ~a" '))) ... - (values ...))) ...)) + (struct _base-type () #:transparent #:mutable) + (struct _subtype _base-type (_field ...) #:transparent #:mutable + #:guard (λ(_field ... name) + (unless (_field-predicate? _field) + (error name (format "arg ~a is not ~a" _field '_field-predicate?))) ... + (values _field ...))) ...)) (define-datatype lc-exp lc-exp?