explicit pure/merge separation

This commit is contained in:
AF 2022-09-07 22:59:15 +03:00
parent b789b3c9f3
commit 2aa07d7f10
4 changed files with 7 additions and 4 deletions

View File

@ -12,7 +12,10 @@ class PureReduce(Reduce[Pure, Pure], Generic[Pure]):
super().__init__(initial)
async def reduce(self, out: Pure, element: Pure) -> Pure:
return self.merge(out, element)
return self.pure(out, element)
def merge(self, left: Pure, right: Pure) -> Pure:
return self.pure(left, right)
def pure(self, left: Pure, right: Pure) -> Pure:
raise NotImplementedError

View File

@ -8,7 +8,7 @@ class VerifyReduce(PureReduce[bool]):
def __init__(self):
super().__init__(True)
def merge(self, left: bool, right: bool) -> bool:
def pure(self, left: bool, right: bool) -> bool:
assert_true(left)
assert_true(right)
return True

View File

@ -194,7 +194,7 @@ class VerifySubsetAction(
class VerifySubsetReduce(
PureReduce[CheckResult]
):
def merge(self, left: CheckResult, right: CheckResult) -> CheckResult:
def pure(self, left: CheckResult, right: CheckResult) -> CheckResult:
return max(left, right)
def loose(self) -> Reduce[CheckResult, CheckResult]:

View File

@ -16,7 +16,7 @@ __all__ = ('FlowCheque',)
class SumReduce(PureReduce[int]):
def merge(self, left: int, right: int) -> int:
def pure(self, left: int, right: int) -> int:
return left + right