Skip to content

Commit

Permalink
Differ implements Pipeable
Browse files Browse the repository at this point in the history
  • Loading branch information
KhraksMamtsov committed Jan 13, 2025
1 parent 766e852 commit 7844226
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
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

0 comments on commit 7844226

Please sign in to comment.