diff --git a/src/belief-system/beliefSystemMerge.ts b/src/belief-system/beliefSystemMerge.ts index 381ca7a..ca096cb 100644 --- a/src/belief-system/beliefSystemMerge.ts +++ b/src/belief-system/beliefSystemMerge.ts @@ -1,6 +1,6 @@ import { Belief } from "../belief/index.js" -import { isNothing, nothing, type Nothing } from "../cell/index.js" import { implies, merge, type MergeConflict } from "../merge/index.js" +import { isNothing, nothing, type Nothing } from "../nothing/index.js" import type { Reasons } from "../reason/index.js" import { setIsSubsetOf } from "../utils/set/index.js" import { BeliefSystem } from "./BeliefSystem.js" diff --git a/src/cell/Cell.ts b/src/cell/Cell.ts index 1f49a1a..0c5126f 100644 --- a/src/cell/Cell.ts +++ b/src/cell/Cell.ts @@ -1,5 +1,5 @@ +import { nothing, type Nothing } from "../nothing/index.js" import type { Propagator } from "../propagator/index.js" -import { nothing, type Nothing } from "./Nothing.js" export type Cell = { "@type": "Cell" diff --git a/src/cell/index.ts b/src/cell/index.ts index f25016e..4cf255e 100644 --- a/src/cell/index.ts +++ b/src/cell/index.ts @@ -1,4 +1,3 @@ export * from "./addPropagator.js" export * from "./Cell.js" -export * from "./Nothing.js" export * from "./put.js" diff --git a/src/merge/merge-nothing.ts b/src/merge/merge-nothing.ts index eb6be53..deaee81 100644 --- a/src/merge/merge-nothing.ts +++ b/src/merge/merge-nothing.ts @@ -1,5 +1,5 @@ -import { isNothing } from "../cell/index.js" import { defineHandler } from "../generic/index.js" +import { isNothing } from "../nothing/index.js" import { merge } from "./merge.js" function isAnything(x: any): true { diff --git a/src/merge/merge.ts b/src/merge/merge.ts index ae93aca..de72c09 100644 --- a/src/merge/merge.ts +++ b/src/merge/merge.ts @@ -4,26 +4,29 @@ import { defineGeneric } from "../generic/index.js" // // The contract of the generic function merge is that it takes two // arguments the currently known information and the new information -// being supplied, and returns the new aggregate information. If the -// information being supplied is redundant, the merge function should -// return exactly (by `===`) the original information, so that the -// cell can know that the news was redundant and not alert its -// neighbors. If the new information contradicts the old information, -// merge should return a distinguished value indicating the -// contradiction, so that the cell can signal an error. For symmetry -// and future use, if the new information strictly supersedes the old -// (i.e., if the old information would be redundant given the new, but -// the new is not redundant given the old) merge is expected to return -// exactly (by `===`) the new information. - -// # `merge` is not entirely symmetric +// being supplied, and returns the new aggregate information. +// +// - If the information being supplied is redundant, the merge +// function should return exactly (by `===`) the original +// information, so that (when calling the `put` function) the cell +// can know that the news was redundant and not alert its neighbors. +// +// - If the new information contradicts the old information, merge +// should return a distinguished value indicating the contradiction, +// so that the cell can signal an error. For symmetry and future +// use. +// +// - If the new information strictly supersedes the old (i.e., if the +// old information would be redundant given the new, but the new is +// not redundant given the old) merge is expected to return exactly +// (by `===`) the new information. // -// If the first and second arguments represent equivalent information -// but are not equal (by `===`), merge must return the first rather -// than the second. This is a consequence of the asymmetry in the -// cells’ treatment of their existing content versus incoming -// content. Having merge return the wrong one could lead to spurious -// infinite loops. +// - If the first and second arguments represent equivalent +// information but are not equal (by `===`), merge must return the +// first rather than the second. This is a consequence of the +// asymmetry in the cells’ treatment of their existing content +// versus incoming content. Having merge return the wrong one could +// lead to spurious infinite loops. export const merge = defineGeneric() diff --git a/src/monad/belief-monad.ts b/src/monad/belief-monad.ts index 8072bb5..a700baa 100644 --- a/src/monad/belief-monad.ts +++ b/src/monad/belief-monad.ts @@ -1,6 +1,6 @@ import { Belief, isBelief } from "../belief/index.js" -import { isNothing, nothing } from "../cell/Nothing.js" import { defineHandler } from "../generic/index.js" +import { isNothing, nothing } from "../nothing/index.js" import { isFunction } from "../utils/isFunction.js" import { setUnion } from "../utils/set/index.js" import { bind, flatten, fmap } from "./monad.js" diff --git a/src/monad/nothing-monad.ts b/src/monad/nothing-monad.ts index 4bbb2c5..8e8c351 100644 --- a/src/monad/nothing-monad.ts +++ b/src/monad/nothing-monad.ts @@ -1,5 +1,5 @@ -import { isNothing, nothing } from "../cell/Nothing.js" import { defineHandler } from "../generic/index.js" +import { isNothing, nothing } from "../nothing/index.js" import { isFunction } from "../utils/isFunction.js" import { flatten, fmap } from "./monad.js" diff --git a/src/cell/Nothing.ts b/src/nothing/Nothing.ts similarity index 100% rename from src/cell/Nothing.ts rename to src/nothing/Nothing.ts diff --git a/src/nothing/index.ts b/src/nothing/index.ts new file mode 100644 index 0000000..81103f8 --- /dev/null +++ b/src/nothing/index.ts @@ -0,0 +1 @@ +export * from "./Nothing.js"