MCPcopy Index your code
hub / github.com/dry-python/returns / _loop

Method _loop

returns/iterables.py:321–356  ·  view source on GitHub ↗

Protected part of ``loop`` method. Can be replaced in subclasses for better performance, etc.

(
        cls,
        iterable: Iterable[
            KindN[_ApplicativeKind, _FirstType, _SecondType, _ThirdType],
        ],
        acc: KindN[_ApplicativeKind, _UpdatedType, _SecondType, _ThirdType],
        function: Callable[
            [_FirstType],
            Callable[[_UpdatedType], _UpdatedType],
        ],
        concat: Callable[
            [
                KindN[_ApplicativeKind, _FirstType, _SecondType, _ThirdType],
                KindN[_ApplicativeKind, _UpdatedType, _SecondType, _ThirdType],
                KindN[
                    _ApplicativeKind,
                    Callable[
                        [_FirstType],
                        Callable[[_UpdatedType], _UpdatedType],
                    ],
                    _SecondType,
                    _ThirdType,
                ],
            ],
            KindN[_ApplicativeKind, _UpdatedType, _SecondType, _ThirdType],
        ],
    )

Source from the content-addressed store, hash-verified

319
320 @classmethod
321 def _loop(
322 cls,
323 iterable: Iterable[
324 KindN[_ApplicativeKind, _FirstType, _SecondType, _ThirdType],
325 ],
326 acc: KindN[_ApplicativeKind, _UpdatedType, _SecondType, _ThirdType],
327 function: Callable[
328 [_FirstType],
329 Callable[[_UpdatedType], _UpdatedType],
330 ],
331 concat: Callable[
332 [
333 KindN[_ApplicativeKind, _FirstType, _SecondType, _ThirdType],
334 KindN[_ApplicativeKind, _UpdatedType, _SecondType, _ThirdType],
335 KindN[
336 _ApplicativeKind,
337 Callable[
338 [_FirstType],
339 Callable[[_UpdatedType], _UpdatedType],
340 ],
341 _SecondType,
342 _ThirdType,
343 ],
344 ],
345 KindN[_ApplicativeKind, _UpdatedType, _SecondType, _ThirdType],
346 ],
347 ) -> KindN[_ApplicativeKind, _UpdatedType, _SecondType, _ThirdType]:
348 """
349 Protected part of ``loop`` method.
350
351 Can be replaced in subclasses for better performance, etc.
352 """
353 wrapped = acc.from_value(function)
354 for current in iterable:
355 acc = concat(current, acc, wrapped)
356 return acc
357
358
359# Helper functions

Callers 3

loopMethod · 0.45
_collectMethod · 0.45
_collect_allMethod · 0.45

Calls 1

from_valueMethod · 0.45

Tested by

no test coverage detected