From 59dfb386a1bb214a69b2183f48f45683d5db52be Mon Sep 17 00:00:00 2001 From: Xie Yuheng Date: Mon, 24 Jun 2024 07:18:45 +0800 Subject: [PATCH] rename `supported.content` to `supported.value` --- TODO.md | 2 -- src/dependency/Supported.ts | 6 +++--- src/dependency/supportedMerge.ts | 6 +++--- src/monads/supported-monad.ts | 6 +++--- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/TODO.md b/TODO.md index 2acd826..8105fed 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,3 @@ -rename `supported.content` to `supported.value` - > propagator 支持 dependencies for provenance > > - https://github.com/cicada-lang/propagator/issues/2 diff --git a/src/dependency/Supported.ts b/src/dependency/Supported.ts index 1054dd1..33c5d63 100644 --- a/src/dependency/Supported.ts +++ b/src/dependency/Supported.ts @@ -2,14 +2,14 @@ import { isNonNullObject } from "../utils/isNonNullObject.js" export type Supported = { "@type": "Supported" - content: T + value: T supports: Set } -export function Supported(content: T, supports: Set): Supported { +export function Supported(value: T, supports: Set): Supported { return { "@type": "Supported", - content, + value, supports, } } diff --git a/src/dependency/supportedMerge.ts b/src/dependency/supportedMerge.ts index cac4a62..60b411a 100644 --- a/src/dependency/supportedMerge.ts +++ b/src/dependency/supportedMerge.ts @@ -6,13 +6,13 @@ export function supportedMerge( content: Supported, increment: Supported, ): Supported | 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 真的有更多信息。 @@ -26,7 +26,7 @@ export function supportedMerge( return content } - if (mergedContent === increment.content) { + if (mergedContent === increment.value) { return increment } diff --git a/src/monads/supported-monad.ts b/src/monads/supported-monad.ts index e43ca91..cb18663 100644 --- a/src/monads/supported-monad.ts +++ b/src/monads/supported-monad.ts @@ -6,18 +6,18 @@ import { setUnion } from "../utils/Set.js" import { isFunction } from "../utils/isFunction.js" defineHandler(fmap, [isFunction, isSupported], (f, ma: Supported) => - 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)), )