46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
from typing import TypeVar
|
|
|
|
from rainbowadn.flow.core import *
|
|
from rainbowadn.flow.sequence import *
|
|
from rainbowadn.flow.stacked import *
|
|
from rainbowadn.flow.verification.core import *
|
|
from rainbowadn.nullability import *
|
|
|
|
__all__ = ('chain_verification',)
|
|
|
|
Link = TypeVar('Link')
|
|
Chain = TypeVar('Chain')
|
|
|
|
|
|
def chain_verification(
|
|
chain_to_dispatched: Mapper[Chain, Reducer[SequenceDispatcher[Link, bool], bool]],
|
|
link_verification: Verification[tuple[Nullable[Link], Link]],
|
|
) -> Verification[
|
|
Chain
|
|
]:
|
|
assert isinstance(chain_to_dispatched, Mapper)
|
|
assert isinstance(link_verification, Verification)
|
|
dispatched_to_stacked: Mapper[
|
|
Reducer[SequenceDispatcher[Link, bool], bool],
|
|
Reducer[tuple[Nullable[Link], Link], bool]
|
|
] = StackedReducer.mapper()
|
|
assert isinstance(dispatched_to_stacked, Mapper)
|
|
chain_to_stacked: Mapper[
|
|
Chain,
|
|
Reducer[tuple[Nullable[Link], Link], bool]
|
|
] = Composition(
|
|
chain_to_dispatched,
|
|
dispatched_to_stacked
|
|
)
|
|
assert isinstance(chain_to_stacked, Mapper)
|
|
stacked_verification: Verification[
|
|
Reducer[tuple[Nullable[Link], Link], bool]
|
|
] = ReduceVerification(link_verification).loose()
|
|
assert isinstance(stacked_verification, Verification)
|
|
verification: Verification[Chain] = CompositionVerification(
|
|
chain_to_stacked,
|
|
stacked_verification
|
|
)
|
|
assert isinstance(verification, Verification)
|
|
return verification
|