purescript-prelude icon indicating copy to clipboard operation
purescript-prelude copied to clipboard

Guide type inference for Record type class instances via newtypes, not Proxies

Open JordanMartinez opened this issue 3 years ago • 0 comments

Description of the change

While working on purescript-json-codecs, I realized that all these proxy args used to guide type inference could be replaced with newtypes now that we have polykinds and explicit kind signatures. Doing so removes one or two curried functions from the resulting code at the cost of some readability.

Naming used was the first letter of the type class name (e.g. S for Semigroup) followed by Record. If two newtypes were needed, then 1 or 2 was thrown in there somewhere.

Throughout this code, I only really use 2-3 newtypes. I wonder if these newtypes should actually be defined somewhere so one can reuse them to implement Record instances for various type classes.

Regardless, if this is accepted, I think the newtypes' names should be changed to prevent users from accidentally importing them since they really are intended to be internal. Perhaps something like __SRecord1?


Checklist:

  • [ ] Added the change to the changelog's "Unreleased" section with a reference to this PR (e.g. "- Made a change (#0000)")
  • [ ] Linked any existing issues or proposals that this pull request should close
  • [ ] Updated or added relevant documentation
  • [ ] Added a test for the contribution (if applicable)

JordanMartinez avatar Oct 30 '22 05:10 JordanMartinez