Skip to content

Commit

Permalink
rename supported.content to supported.value
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Jun 23, 2024
1 parent 911b81a commit 59dfb38
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
rename `supported.content` to `supported.value`

> propagator 支持 dependencies for provenance
>
> - https://github.com/cicada-lang/propagator/issues/2
Expand Down
6 changes: 3 additions & 3 deletions src/dependency/Supported.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { isNonNullObject } from "../utils/isNonNullObject.js"

export type Supported<T> = {
"@type": "Supported"
content: T
value: T
supports: Set<string>
}

export function Supported<T>(content: T, supports: Set<string>): Supported<T> {
export function Supported<T>(value: T, supports: Set<string>): Supported<T> {
return {
"@type": "Supported",
content,
value,
supports,
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/dependency/supportedMerge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export function supportedMerge<A, B>(
content: Supported<A>,
increment: Supported<B>,
): Supported<A | B> | Contradiction {
const mergedContent = merge(content.content, increment.content)
const mergedContent = merge(content.value, increment.value)

// 这里的 cases 可以写成更对称的样子,
// 但是这里为了效率(少调用 merge 的次数),
// 写的不是那么对称了。

if (mergedContent === content.content) {
if (mergedContent === content.value) {
// 正向和反向的 implies 代表等价。
if (implies(increment, content)) {
// 倾向于 content,除非 increment 真的有更多信息。
Expand All @@ -26,7 +26,7 @@ export function supportedMerge<A, B>(
return content
}

if (mergedContent === increment.content) {
if (mergedContent === increment.value) {
return increment
}

Expand Down
6 changes: 3 additions & 3 deletions src/monads/supported-monad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import { setUnion } from "../utils/Set.js"
import { isFunction } from "../utils/isFunction.js"

defineHandler(fmap, [isFunction, isSupported], (f, ma: Supported<any>) =>
Supported(bind(ma.content, f), ma.supports),
Supported(bind(ma.value, f), ma.supports),
)

defineHandler(join, [isSupported], (ma) => ma)
defineHandler(
join,
[(ma) => isSupported(ma) && isNothing(ma.content)],
[(ma) => isSupported(ma) && isNothing(ma.value)],
(ma) => nothing,
)
defineHandler(
join,
[(mma) => isSupported(mma) && isSupported(mma.content)],
[(mma) => isSupported(mma) && isSupported(mma.value)],
(mma) =>
join(mma.content.content, setUnion(mma.supports, mma.content.supports)),
)

0 comments on commit 59dfb38

Please sign in to comment.