Skip to content

Free applicative

FreeA

Bases: Generic[F, A]

summary

Parameters:

Name Type Description Default
Generic _type_

description

required

Returns:

Name Type Description
_type_

description

Source code in funclift/free_applicative.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class FreeA(Generic[F, A]):
    """_summary_

    Args:
        Generic (_type_): _description_

    Returns:
        _type_: _description_
    """

    @staticmethod
    def pure(a: B) -> FreeA[F, B]:
        return Pure(a)

    @staticmethod
    def lift(fa: Functor[F, A]) -> Lift[F, A]:
        return Lift(fa)

    @abstractmethod
    def fmap(self, f: Callable[[A], B]) -> FreeA[F, B]: ...

    # def ap(self: FreeA[F, E], a: Functor[F, C]) -> Functor[F, E]: ...
    # def ap(self: FreeA[F, A], b: FreeA[F, Callable[[A], B]]) -> FreeA[F, B]:
    #     if isinstance(b, Pure):
    #         return self.fmap(b.a)

    #     return Ap(b, self)

    @abstractmethod
    def ap(self: FreeA[F, Callable[[B], C]], b: FreeA[F, B]) -> FreeA[F, C]:
        ...

    @abstractmethod
    def foldmap(self, nt: FunctionK[F, G]) -> Applicative[G, A]: ...