Skip to content
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

Differ implements Pipeable #4239

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rude-rules-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": minor
---

`Differ` implements `Pipeable`
3 changes: 2 additions & 1 deletion packages/effect/src/Differ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as HashMapPatch from "./internal/differ/hashMapPatch.js"
import * as HashSetPatch from "./internal/differ/hashSetPatch.js"
import * as OrPatch from "./internal/differ/orPatch.js"
import * as ReadonlyArrayPatch from "./internal/differ/readonlyArrayPatch.js"
import type { Pipeable } from "./Pipeable.js"
import type * as Types from "./Types.js"

/**
Expand Down Expand Up @@ -48,7 +49,7 @@ export type TypeId = typeof TypeId
* @since 2.0.0
* @category models
*/
export interface Differ<in out Value, in out Patch> {
export interface Differ<in out Value, in out Patch> extends Pipeable {
readonly [TypeId]: {
readonly _V: Types.Invariant<Value>
readonly _P: Types.Invariant<Patch>
Expand Down
4 changes: 4 additions & 0 deletions packages/effect/src/internal/differ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as Dual from "../Function.js"
import { constant, identity } from "../Function.js"
import type { HashMap } from "../HashMap.js"
import type { HashSet } from "../HashSet.js"
import { pipeArguments } from "../Pipeable.js"
import * as ChunkPatch from "./differ/chunkPatch.js"
import * as ContextPatch from "./differ/contextPatch.js"
import * as HashMapPatch from "./differ/hashMapPatch.js"
Expand All @@ -22,6 +23,9 @@ export const DifferProto = {
[DifferTypeId]: {
_P: identity,
_V: identity
},
pipe() {
return pipeArguments(this, arguments)
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/effect/test/Differ.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ describe("Differ", () => {

describe("tuple", () => {
diffLaws(
pipe(Differ.update<number>(), Differ.zip(Differ.update<number>())),
Differ.update<number>()
.pipe(
Differ.zip(Differ.update<number>())
),
randomPair,
(a, b) => Equal.equals(a[0], b[0]) && Equal.equals(a[1], b[1])
)
Expand Down
Loading