-
-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Make Equal an implicit trait, namely remove the type Data.Data (#…
- Loading branch information
1 parent
a1604c0
commit ccacaec
Showing
23 changed files
with
194 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
"@effect/platform": minor | ||
"effect": minor | ||
"@effect/schema": minor | ||
"@effect/cli": minor | ||
"@effect/rpc": minor | ||
--- | ||
|
||
With this change we remove the `Data.Data` type and we make `Equal.Equal` & `Hash.Hash` implicit traits. | ||
|
||
The main reason is that `Data.Data<A>` was structurally equivalent to `A & Equal.Equal` but extending `Equal.Equal` doesn't mean that the equality is implemented by-value, so the type was simply adding noise without gaining any level of safety. | ||
|
||
The module `Data` remains unchanged at the value level, all the functions previously 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: | ||
|
||
```ts | ||
import { Data } from "effect"; | ||
|
||
const obj = Data.struct({ | ||
a: 0, | ||
b: 1, | ||
}); | ||
``` | ||
|
||
will have the `obj` typed as: | ||
|
||
```ts | ||
declare const obj: { | ||
readonly a: number; | ||
readonly b: number; | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.