mirror of
https://github.com/correl/typesafe-monads.git
synced 2024-11-14 11:09:36 +00:00
Give Curried its own __repr__ implementation
Because a curried function annotation will be based on the original function signature (won't match Env -> T), I'd rather differentiate its representation. Otherwise, it looks like something messed up building a Reader.
This commit is contained in:
parent
375e5a47e1
commit
3d312c1c90
1 changed files with 13 additions and 5 deletions
|
@ -13,11 +13,19 @@ E = TypeVar("E")
|
|||
Result = TypeVar("Result")
|
||||
|
||||
|
||||
class CurriedUnary(Reader[A, Result]):
|
||||
class Curried(Reader[A, Result]):
|
||||
def __repr__(self): # pragma: no cover
|
||||
module = self.function.__module__
|
||||
name = self.function.__name__
|
||||
signature = inspect.signature(self)
|
||||
return f"<Curried {module}.{name}{signature}>"
|
||||
|
||||
|
||||
class CurriedUnary(Curried[A, Result]):
|
||||
...
|
||||
|
||||
|
||||
class CurriedBinary(Reader[A, CurriedUnary[B, Result]]):
|
||||
class CurriedBinary(Curried[A, CurriedUnary[B, Result]]):
|
||||
@overload
|
||||
def __call__(self, environment: A) -> CurriedUnary[B, Result]:
|
||||
...
|
||||
|
@ -30,7 +38,7 @@ class CurriedBinary(Reader[A, CurriedUnary[B, Result]]):
|
|||
return reduce(lambda f, x: f(x), args, self.function)
|
||||
|
||||
|
||||
class CurriedTernary(Reader[A, CurriedBinary[B, C, Result]]):
|
||||
class CurriedTernary(Curried[A, CurriedBinary[B, C, Result]]):
|
||||
@overload
|
||||
def __call__(self, environment: A) -> CurriedBinary[B, C, Result]:
|
||||
...
|
||||
|
@ -47,7 +55,7 @@ class CurriedTernary(Reader[A, CurriedBinary[B, C, Result]]):
|
|||
return reduce(lambda f, x: f(x), args, self.function)
|
||||
|
||||
|
||||
class CurriedQuaternary(Reader[A, CurriedTernary[B, C, D, Result]]):
|
||||
class CurriedQuaternary(Curried[A, CurriedTernary[B, C, D, Result]]):
|
||||
@overload
|
||||
def __call__(self, environment: A) -> CurriedTernary[B, C, D, Result]:
|
||||
...
|
||||
|
@ -68,7 +76,7 @@ class CurriedQuaternary(Reader[A, CurriedTernary[B, C, D, Result]]):
|
|||
return reduce(lambda f, x: f(x), args, self.function)
|
||||
|
||||
|
||||
class CurriedQuinary(Reader[A, CurriedQuaternary[B, C, D, E, Result]]):
|
||||
class CurriedQuinary(Curried[A, CurriedQuaternary[B, C, D, E, Result]]):
|
||||
@overload
|
||||
def __call__(self, environment: A) -> CurriedQuaternary[B, C, D, E, Result]:
|
||||
...
|
||||
|
|
Loading…
Reference in a new issue