jackfirth / rebellion

A collection of core libraries for Racket
https://pkgs.racket-lang.org/package/rebellion
Apache License 2.0
83 stars 16 forks source link

Add enum type bindings #437

Closed jackfirth closed 4 years ago

jackfirth commented 4 years ago

This pull request adds static type information for enum types, in the form of enum bindings. Enum bindings are created by define-enum-type and can be extracted with the enum-id syntax class. Additionally, this pull request implements an enum-out provide transformer.

An unfortunate breaking change to rebellion/base/range is included: the range-bound-type enum is renamed to bound-type, to avoid a clash between the enum binding and the range-bound-type accessor for the type field of range-bound.

This pull request paves the way for compile-time manipulation of enums, such as defining converters between different enums or converters from enums to symbols and strings. It also sets a precedent for how other kinds of types will expose compile-time information.

Partially addresses #431, though docs for enum-type? and enum type descriptors are still lacking.