Skip to content

Commit

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

[refactoring] extract `implies`

[refactoring] should not define handlers of `merge` in one file
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-nothing.js"
export * from "./merge-number.js"
export * from "./merge.js"
// export * from "./merge-nothing.js"
export * from "./MergeConflict.js"
10 changes: 10 additions & 0 deletions src/merge/merge-nothing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { isNothing } from "../cell/index.js"
import { defineHandler } from "../generic/index.js"
import { merge } from "./merge.js"

function isAnything(x: any): true {
return true
}

defineHandler(merge, [isAnything, isNothing], (content, increment) => content)
defineHandler(merge, [isNothing, isAnything], (content, increment) => increment)
10 changes: 1 addition & 9 deletions src/merge/merge.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { isNothing } from "../cell/index.js"
import { defineGeneric, defineHandler } from "../generic/index.js"
import { defineGeneric } from "../generic/index.js"
import { log } from "../utils/log.js"

// # The contract of `merge`
Expand Down Expand Up @@ -70,10 +69,3 @@ export const merge = defineGeneric({
export function implies<A, B>(x: A, y: B): boolean {
return merge(x, y) === x
}

function isAnything(x: any): true {
return true
}

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

0 comments on commit f9bc87f

Please sign in to comment.