Skip to content

Functor

Functor

Bases: Generic[F, A], Protocol

Functor

Source code in funclift/functor.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class Functor(Generic[F, A], Protocol):
    """Functor"""

    def fmap(self, f: Callable[[A], B]) -> Functor[F, B]:
        """
        fmap takes a function of type A -> B and produces a value of type F[B].

        Args:
            f (Callable[[A], B]): A function of type A -> B

        Returns:
            Functor[F, B]: A value of type F[B]
        """
        ...

fmap(f)

fmap takes a function of type A -> B and produces a value of type F[B].

Parameters:

Name Type Description Default
f Callable[[A], B]

A function of type A -> B

required

Returns:

Type Description
Functor[F, B]

Functor[F, B]: A value of type F[B]

Source code in funclift/functor.py
15
16
17
18
19
20
21
22
23
24
25
def fmap(self, f: Callable[[A], B]) -> Functor[F, B]:
    """
    fmap takes a function of type A -> B and produces a value of type F[B].

    Args:
        f (Callable[[A], B]): A function of type A -> B

    Returns:
        Functor[F, B]: A value of type F[B]
    """
    ...