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

Handle Functor Composition in Generic Instances #1103

Closed
wants to merge 1 commit into from

Conversation

julmb
Copy link

@julmb julmb commented Jun 4, 2024

This fixes all cases of #1059 that are known to me.

The changes are minimally-invasive with regard to the existing setup. However, they only allow the pattern f :.: Rec1 g for composition. I do not know if this covers all the cases that can arise with DeriveGeneric or if there is maybe a more clever way to set things up (see #1059 (comment)).

I am submitting this as a draft pull request since I still need to check some things and add regression tests. Since I barely understand the existing infrastructure, I would be grateful for early feedback on whether the proposed implementation is on the right track.

Once completed, I would only want this to be merged after someone more knowledgeable takes a critical look at it.

Tasks:

  • add missing instances
  • check if optional fields are handled correctly
  • add regression test

@julmb
Copy link
Author

julmb commented Jun 10, 2024

This does not work in all cases since a field like bar :: Maybe (Maybe (Maybe a)) will be represented as Maybe :.: (Maybe :.: Rec1 Maybe), which the instance RecordFromJSON' One (S1 s (f :.: Rec1 g)) cannot handle. An instance like RecordFromJSON' One (S1 s (f :.: g)) does not work since there is no type class that provides field omission functionality on generic representations.

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