Skip to content

Commit

Permalink
[refactoring] extract merge-number
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Sep 4, 2024
1 parent 50c9d3f commit 8ae6c76
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[refactoring] extract `merge-number`
[refactoring] extract `merge-nothing`

[refactoring] extract `implies`
Expand Down
2 changes: 1 addition & 1 deletion src/merge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export * from "./detectMergeConflict.js"
export * from "./merge-belief-system.js"
export * from "./merge-belief.js"
export * from "./merge-interval.js"
export * from "./merge-number.js"
export * from "./merge.js"
// export * from "./merge-number.js"
// export * from "./merge-nothing.js"
export * from "./MergeConflict.js"
8 changes: 8 additions & 0 deletions src/merge/merge-number.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineHandler } from "../generic/index.js"
import { isNumber } from "../utils/isNumber.js"
import { merge } from "./merge.js"
import { theMergeConflict } from "./MergeConflict.js"

defineHandler(merge, [isNumber, isNumber], (content, increment) =>
increment === content ? content : theMergeConflict,
)
6 changes: 0 additions & 6 deletions src/merge/merge.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { isNothing } from "../cell/index.js"
import { defineGeneric, defineHandler } from "../generic/index.js"
import { isNumber } from "../utils/isNumber.js"
import { log } from "../utils/log.js"
import { theMergeConflict } from "./MergeConflict.js"

// # The contract of `merge`
// The contract of the generic function merge is that it takes two
Expand Down Expand Up @@ -79,7 +77,3 @@ function isAnything(x: any): true {

defineHandler(merge, [isAnything, isNothing], (content, increment) => content)
defineHandler(merge, [isNothing, isAnything], (content, increment) => increment)

defineHandler(merge, [isNumber, isNumber], (content, increment) =>
increment === content ? content : theMergeConflict,
)

0 comments on commit 8ae6c76

Please sign in to comment.