@@ -432,21 +432,14 @@ def __repr__(self) -> str:
432432 return str (self )
433433
434434
435- class ExitFn (Protocol ):
435+ class Cata (Protocol [ TSource , TResult ] ):
436436 """A partially applied exit function."""
437437
438- def __call__ (self , source : FrozenList [TSource ]) -> TSource :
438+ def __call__ (self , source : FrozenList [TSource ]) -> TResult :
439439 ...
440440
441441
442- class FilterFn (Protocol ):
443- """A partially applied filter function."""
444-
445- def __call__ (self , __source : FrozenList [TSource ]) -> FrozenList [TSource ]:
446- ...
447-
448-
449- class TransformFn (Protocol [TResult ]):
442+ class Projection (Protocol [TSource , TResult ]):
450443 """A partially applied filter function."""
451444
452445 def __call__ (self , __source : FrozenList [TSource ]) -> FrozenList [TResult ]:
@@ -592,7 +585,7 @@ def indexed(source: FrozenList[TSource]) -> FrozenList[Tuple[int, TSource]]:
592585 return source .indexed ()
593586
594587
595- def item (index : int ) -> ExitFn :
588+ def item (index : int ) -> Cata [ TSource , TSource ] :
596589 """Indexes into the list. The first element has index 0.
597590
598591 Args:
@@ -608,12 +601,12 @@ def _item(source: FrozenList[TSource]) -> TSource:
608601 return _item
609602
610603
611- def is_empty (source : FrozenList [TSource ]) -> bool :
604+ def is_empty (source : FrozenList [Any ]) -> bool :
612605 """Returns `True` if the list is empty, `False` otherwise."""
613606 return source .is_empty ()
614607
615608
616- def map (mapper : Callable [[TSource ], TResult ]) -> TransformFn [ TResult ]:
609+ def map (mapper : Callable [[TSource ], TResult ]) -> Projection [ TSource , TResult ]:
617610 """Map list.
618611
619612 Builds a new collection whose elements are the results of applying
@@ -671,7 +664,7 @@ def singleton(value: TSource) -> FrozenList[TSource]:
671664 return FrozenList ((value ,))
672665
673666
674- def skip (count : int ) -> FilterFn :
667+ def skip (count : int ) -> Projection [ TSource , TSource ] :
675668 """Returns the list after removing the first N elements.
676669
677670 Args:
@@ -687,7 +680,7 @@ def _skip(source: FrozenList[TSource]) -> FrozenList[TSource]:
687680 return _skip
688681
689682
690- def skip_last (count : int ) -> FilterFn :
683+ def skip_last (count : int ) -> Projection [ TSource , TSource ] :
691684 """Returns the list after removing the last N elements.
692685
693686 Args:
@@ -707,7 +700,7 @@ def tail(source: FrozenList[TSource]) -> FrozenList[TSource]:
707700 return source .tail ()
708701
709702
710- def take (count : int ) -> FilterFn :
703+ def take (count : int ) -> Projection [ TSource , TSource ] :
711704 """Returns the first N elements of the list.
712705
713706 Args:
@@ -723,7 +716,7 @@ def _take(source: FrozenList[TSource]) -> FrozenList[TSource]:
723716 return _take
724717
725718
726- def take_last (count : int ) -> FilterFn :
719+ def take_last (count : int ) -> Projection [ TSource , TSource ] :
727720 """Returns a specified number of contiguous elements from the end of
728721 the list.
729722
0 commit comments