Skip to content

Conversation

@JordanMartinez
Copy link
Contributor

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 JordanMartinez changed the title Guide type inference via newtypes, not Proxies Guide type inference for Record type class instances via newtypes, not Proxies Oct 30, 2022
@JordanMartinez
Copy link
Contributor Author

Closing due to no activity here.

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