-
-
Notifications
You must be signed in to change notification settings - Fork 181
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
feat: Make Equal an implicit trait, namely remove the type Data.Data #2023
Conversation
🦋 Changeset detectedLatest commit: 3cfcd29 The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There is a pitfall in this though, users might unwittingly squander the pipe(
ReadonlyArray.makeBy(10, () => new A()),
Data.array,
Effect.forEach(_ => Effect.as(notifyMikeAboutA(_), _))
Effect.filterOrDie(
Equal.equals(Data.array(ReadonlyArray.makeBy(10, () => new A()))),
() => "w00t"
)
) // -> it dies with w00t |
That's correct as forEach returns a new copy of the array which is mutable, I guess it is a trade-off, we could also make |
I can't come up with a solution for this pitfall, I guess we will just have to make sure to note it in the docs. |
I can't find any more typos 👎 |
1d42f4b
to
3590bbb
Compare
3590bbb
to
3cfcd29
Compare
@mikearnaldi hmmm the bot (and @/gcanti 😃 ) is quite noisy here, is this a one-time or will all updates be this noisy until they publish? |
With this change we remove the
Data.Data
type and we makeEqual.Equal
&Hash.Hash
an implicit traits.The main reason is that
Data.Data<A>
was structurally equivalent toA & Equal.Equal
but extendingEqual.Equal
doesn't mean that the equality is implemented by-value, so the type was simply adding noice without gaining any level of safety.The module
Data
remains unchanged at the value level, all the functions priorly available are supposed to work in exactly the same manner.At the type level instead the functions return
Readonly
variants, so for example we have:will have the
obj
typed as:closes #1962