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

Suggestion: Polykinded On + OnTarget class #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

gusbicalho
Copy link

This splits functionality on On into a typeclass to allow adding new types that implement targets for it. The typeclass dispatches on a kind, so we can still have the general "Symbol implies HasField" behaviour. I then took advantage of that to add:

  • and instance for pairs of targets
  • an Nth type that can be used to index fields by their position, using GHC Generics.

I can see how this may end up overcomplicating the design, but the end result looks nice to me. Any other field accessors will now only need to define a single instance.

I have very little experience with GHC Generics, so I don't know if there's a better way to write the code in Deriving.On.Nth.

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.

1 participant