diff --git a/TODO.md b/TODO.md index 60f8f6a..7df6b3d 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,3 @@ -[refactoring] extract `merge-nothing` - [refactoring] extract `implies` [refactoring] should not define handlers of `merge` in one file diff --git a/src/merge/index.ts b/src/merge/index.ts index ad41461..4d2f039 100644 --- a/src/merge/index.ts +++ b/src/merge/index.ts @@ -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" diff --git a/src/merge/merge-nothing.ts b/src/merge/merge-nothing.ts new file mode 100644 index 0000000..eb6be53 --- /dev/null +++ b/src/merge/merge-nothing.ts @@ -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) diff --git a/src/merge/merge.ts b/src/merge/merge.ts index edba9d5..107a9a9 100644 --- a/src/merge/merge.ts +++ b/src/merge/merge.ts @@ -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` @@ -70,10 +69,3 @@ export const merge = defineGeneric({ export function implies(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)