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

Field normalization #419

Open jackfirth opened 4 years ago

jackfirth commented 4 years ago

Sometimes a data type wants to normalize values for a field, usually so it can accept a broad range of inputs while still preserving meaningful equality semantics. For example, a board game data type may wish to represent the pieces on the board as a set?, but allow construction from any sequence? of pieces. In order to keep equality sensible, at construction time the sequence of pieces should be deduplicated and placed into an unordered set? so that the order of the input sequence doesn't affect whether two boards are equal?.

It would be handy to have some integration with rebellion/type for this kind of thing. Whether that means a #:normalizer keyword on fields or some sort of normalizer? abstraction, I have no idea. Further research required.