File: bimappable.py

package info (click to toggle)
python-returns 0.26.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,652 kB
  • sloc: python: 11,000; makefile: 18
file content (33 lines) | stat: -rw-r--r-- 847 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from typing import TypeVar

from typing_extensions import Never

from returns.interfaces import altable, mappable

_FirstType = TypeVar('_FirstType')
_SecondType = TypeVar('_SecondType')
_ThirdType = TypeVar('_ThirdType')


class BiMappableN(
    mappable.MappableN[_FirstType, _SecondType, _ThirdType],
    altable.AltableN[_FirstType, _SecondType, _ThirdType],
):
    """
    Allows to change both types of a container at the same time.

    Uses ``.map`` to change first type and ``.alt`` to change second type.

    See also:
        - https://typelevel.org/cats/typeclasses/bifunctor.html

    """

    __slots__ = ()


#: Type alias for kinds with two type arguments.
BiMappable2 = BiMappableN[_FirstType, _SecondType, Never]

#: Type alias for kinds with three type arguments.
BiMappable3 = BiMappableN[_FirstType, _SecondType, _ThirdType]