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

Proposal: Remove HFunctor's fmap' with GHCs supporting QuantifiedConstraints. #153

Closed
wants to merge 1 commit into from

Conversation

patrickt
Copy link
Collaborator

As was mentioned in the HFunctor documentation, we can eliminate the
vestigial fmap' method with QuantifiedConstraints. This implementation
is provided by Bottu et al.'s Quantified Class Constraints.

The advantage of this patch is that it expresses the nature of
HFunctor in a more direct manner, rather than with the
dummy-function workaround. The disadvantage is that only GHC 8.6
supports QuantifiedConstraints, so we have to use CPP to define the
polyfill (as it were) to handle it.

This changes the HFunctor interface but should maintain
compatibility, as fmap' was never implemented by hand outside of Sum.

As was mentioned in the `HFunctor` documentation, we can eliminate the
vestigial `fmap'` method with QuantifiedConstraints. This implementation
is provided by Bottu et al.'s _Quantified Class Constraints_.

The advantage of this patch is that it expresses the nature of
`HFunctor` in a more direct manner, rather than with the
dummy-function workaround. The disadvantage is that only GHC 8.6
supports QuantifiedConstraints, so we have to use CPP to define the
polyfill (as it were) to handle it.

This changes the `HFunctor` interface but should maintain
compatibility, as `fmap'` was never implemented by hand outside of `Sum`.
@mitchellwrosen
Copy link
Contributor

If CPP+QuantifiedConstraints is on the table, perhaps this newtype could make it in as well?

@patrickt
Copy link
Collaborator Author

@mitchellwrosen I don't see why not. In my industrial experience, most people are pinned to relatively recent GHCs, so I think it behooves us to program for the newest GHC available. @robrix has the final say on it though.

@robrix
Copy link
Contributor

robrix commented Apr 12, 2019

We’d be forcing QuantifiedConstraints on Sum as well, but likely not on other consumers. Still, I’m not (personally) super interested in going this route until we drop support for 8.6. (That said, interested parties should feel free to convince me!)

@robrix
Copy link
Contributor

robrix commented Apr 12, 2019

I wonder if we could do something like Simulating Quantified Class Constraints?

@robrix
Copy link
Contributor

robrix commented Apr 14, 2019

Upon reflection I think the question I’m left with is: what problem is this solving for users? It complicates the code & build process somewhat, and (AFAICS) doesn’t really improve the usability of the library.

On the balance, I think I’d rather not go this route, until such time as we only support 8.6+.

@patrickt
Copy link
Collaborator Author

I think that’s fair. Closing this for now.

@patrickt patrickt closed this Apr 14, 2019
@patrickt patrickt deleted the remove-fmap'-with-qcs branch April 14, 2019 19:16
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.

None yet

3 participants