-
Notifications
You must be signed in to change notification settings - Fork 13
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
RFC: Make Some
into a newtype around Some
from package some
#142
base: master
Are you sure you want to change the base?
Conversation
The `Some` type from package `some` is a newtype, and is correspondingly more performant than our previous data-based encoding. This change will require a major version bump and an easy but still mandatory migration for downstream codebases. Downstream code will either need to switch to using the eliminator, or using pattern synonyms. Example migrations to use pattern synonyms can be seen in this commit. This patch also uses GeneralizedNewtypeDeriving to derive the upstream `Semigroup` and `Monoid` instances, which are a good demonstration of the utility of sharing an implementation with a well-thought-out upstream package.
8fa5b12
to
fadb675
Compare
Is #62 the primary motivation for this? If so, I wonder if making The performance benefits from using a newtype encoding of |
Let me make a more comprehensive pro/con list, as I should have done in the PR description: Cons:
Pros:
|
OK. If I'm reading the pros correctly, most of the benefits involve the |
Right, great question. The problem is instances. For example, we have |
Ah, OK. If we do decide to go down this path, it would be worthwhile to nail down exactly what the desired end state would be. I'm still unclear on what we actually want: Do we want to use a redefined version of |
I share the concern about GEq/TestEquality differences (as well as API changes). I wonder if maybe first we should deprecate |
The
Some
type from packagesome
is a newtype, and is correspondingly more performant than our previousdata
-based encoding.This change will require a major version bump and an easy but still mandatory migration for downstream codebases. Downstream code will either need to switch to using the eliminator (
viewSome
), or using pattern synonyms. Example migrations to use pattern synonyms can be seen in this commit.This patch also uses
-XGeneralizedNewtypeDeriving
to derive the upstreamSemigroup
andMonoid
instances, which are a good demonstration of the utility of sharing an implementation with a well-thought-out upstream package.In the long run, I hope this paves the way towards #62. I'm not 100% sure this PR is the right way to go, but I realized that this was possible and thought it was worth a discussion.