typed-racket-datatypeπ i
Source code:
https://github.com/AlexKnauth/typed-racket-datatype.
Provides
define-datatype , a form for defining
Algebraic Data Types in Typed Racket.
header = name-id
| (name-idparam-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
(variant-id[field-id: field-type]... )
is equivalent to
(struct variant-id([field-id: field-type]... )#:transparent)