8.16.0.4
typed-racket-datatype
Source code: https://github.com/AlexKnauth/typed-racket-datatype.
Provides define-datatype, a form for defining
Algebraic Data Types in Typed Racket.
syntax
(define-datatype header (variant-id field ...) ...)
header = name-id | (name-id param-id ...) field = [field-id : field-type]
Defines name-id as an Algebraic Data Type with the
given variant-ids defined as structs with their
respective fields. If param-ids are
provided, the name-id type and the
variant-id structs are all polymorphic with those
param-ids, otherwise they are monomorphic.
Each variant struct includes a predicate and field accessors, and define-datatype also generates a predicate name-id? that accepts values that pass any of the variant predicates.
For example
(define-datatype name-id (variant-id [field-id : field-type] ...) ...)
is equivalent to