Use Unicode Greek alphabets for visual representation of CGP field types#85
Merged
soareschen merged 7 commits intomainfrom Apr 1, 2025
Merged
Use Unicode Greek alphabets for visual representation of CGP field types#85soareschen merged 7 commits intomainfrom
soareschen merged 7 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR redefines the base definition of field types to use single Unicode character to represent the type. This significantly simplifies the visual representation of field types in error messages and IDEs, so that they can be read more easily.
Mappings
The field types now have the following mapping:
Char-ιIndex-δCons-πNil-εEither-σVoid-θField-ωASCII Names
The Unicode field types still re-export their original ASCII names using
pub use. This means that all existing code that use the original ASCII names will continue to work.Changes to
Charandsymbol!The
Chartype has been redesigned to combine withCons, so that the tail type is in the second argument ofChar. This allows the symbol types generated fromsymbol!to have cleaner display, together with the use ofιto further shorten the representation.Considerations
I have chosen to use lowercase instead of uppercase Greek characters for the field types, as they offer cleaner visual representation. The key consieration is that the field types should "look" almost invisible, so that the readers can focus on the "shape" of the overall field types, instead of the individual characters.
Example
Consider the original expansion of the macro for the following product type:
The original expansion would look like:
But the visual representation of the same field type would be:
As we can see, the Unicode types make it much easier to figure out what the field type is, assuming once we are familiarized with what each Greek character means.