Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set ShortName at Type #84

Merged
merged 1 commit into from
Aug 30, 2021

Conversation

dwincort
Copy link
Contributor

In #36, the ability to set a short name was added via Modifiers. In #41, there is a request to make sure these short names are unique. This PR attempts to enhance short-name creation with a type decorator; while it does not prevent duplicate short names, it makes dealing with them much easier.

This PR adds a new decorator <$> ("$" signaling "S", which stands for "Short name", although it can certainly be changed if the connection to fmap is too strong) that allows the short name of a field to be specified in its type. This short name supersedes any that is set by Modifiers; this way, one can use a standard short-name modifier (say, firstLetter), and then manually replace short names of specific fields in the type. Adding <$> "" to a type removes the short name altogether.

Unfortunately, there are no type-level Chars, which means that we're forced to use type-level strings (i.e., Symbol); in this implementation, I opt to ignore all but the first character.

@Gabriella439
Copy link
Owner

Yeah, I'm worried about <$> conflicting with the one exported from the Prelude. Would it be possible to rename this operator to <#>?

@dwincort
Copy link
Contributor Author

Okay, I changed <$> to <#>. How does that look?

@Gabriella439 Gabriella439 merged commit a8f66ee into Gabriella439:master Aug 30, 2021
@Gabriella439
Copy link
Owner

Looks great! Thank you for contributing this 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants