Skip to content

Commit

Permalink
Fix the definitions of felis.free_dict.identity, `felis.free_t.iden…
Browse files Browse the repository at this point in the history
…tity` and `felis.free.identity`
  • Loading branch information
LeeeeT committed Sep 13, 2024
1 parent 94bf977 commit 3f02d54
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/felis/free.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from collections.abc import Callable
from dataclasses import dataclass
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

import felis.identity
from felis import applicative, free_t, function, identity, monad
from felis import applicative, free_t, function, monad
from felis.currying import curry
from felis.free_t import Pure

Expand Down Expand Up @@ -54,6 +54,13 @@ def map[From, To](free_value: Free[From], function: Callable[[From], To]) -> Fre
map = free_t.map(felis.identity.map)


if TYPE_CHECKING:
# [T : Type] -> T -> Free T
identity: Free[Any]
else:
from felis.free_t import identity


if TYPE_CHECKING:

@curry
Expand Down
11 changes: 9 additions & 2 deletions src/felis/free_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from collections.abc import Callable
from dataclasses import dataclass
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

from felis import applicative, dict, free_t, function, monad
from felis.currying import curry
from felis.free_t import Pure, identity
from felis.free_t import Pure

__all__ = [
"Pure",
Expand Down Expand Up @@ -53,6 +53,13 @@ def map[K, From, To](free_dict_value: FreeDict[K, From], function: Callable[[Fro
map = free_t.map(dict.map)


if TYPE_CHECKING:
# [K : Type] -> [T : Type] -> T -> FreeDict K T
identity: FreeDict[Any, Any]
else:
from felis.free_t import identity


if TYPE_CHECKING:

@curry
Expand Down
8 changes: 6 additions & 2 deletions src/felis/free_t.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Callable
from dataclasses import dataclass
from typing import Any
from typing import TYPE_CHECKING, Any

import felis.function
from felis.currying import curry
Expand Down Expand Up @@ -35,7 +35,11 @@ def map[From, To](free_value: Free[From], function: Callable[[From], To], f_map:
return Bind(f_map(map(f_map)(function))(f_free_value))


identity = Pure
if TYPE_CHECKING:
# [F : Type -> Type] -> [T : Type] -> T -> Free F T
identity: Free[Any]
else:
identity = Pure


# [F : Type -> Type] ->
Expand Down

0 comments on commit 3f02d54

Please sign in to comment.