diff options
author | Munyoki Kilyungi | 2022-10-11 12:06:05 +0300 |
---|---|---|
committer | BonfaceKilz | 2022-11-02 17:36:22 +0300 |
commit | 97fa5c174d15858f7466190d7707a36486c19fbe (patch) | |
tree | 9d0b8d443d8af3866960c53a5c9106afdb515ba3 /stubs | |
parent | faf2739d30decda1e0ba46699ebec776ef7d3e0d (diff) | |
download | genenetwork3-97fa5c174d15858f7466190d7707a36486c19fbe.tar.gz |
Add type stubs for Maybe
This allows Maybe[T] to be used as a type. Both Nothing and Just are
of type Maybe.
* mypy.ini: Add default location for stub files.
* stubs/pymonad/__init__.pyi: New file.
* stubs/pymonad/maybe.pyi: Ditto.
Diffstat (limited to 'stubs')
-rw-r--r-- | stubs/pymonad/__init__.pyi | 0 | ||||
-rw-r--r-- | stubs/pymonad/maybe.pyi | 26 |
2 files changed, 26 insertions, 0 deletions
diff --git a/stubs/pymonad/__init__.pyi b/stubs/pymonad/__init__.pyi new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/stubs/pymonad/__init__.pyi diff --git a/stubs/pymonad/maybe.pyi b/stubs/pymonad/maybe.pyi new file mode 100644 index 0000000..abf1433 --- /dev/null +++ b/stubs/pymonad/maybe.pyi @@ -0,0 +1,26 @@ +import pymonad.monad # type: ignore +from _typeshed import Incomplete +from typing import Any, Callable, Generic, TypeVar + +S = TypeVar('S') +T = TypeVar('T') + +class Maybe(pymonad.monad.Monad, Generic[T]): + @classmethod + def insert(cls, value: T) -> Maybe[T]: ... + def amap(self, monad_value: Maybe[S]) -> Maybe[T]: ... + def bind(self, kleisli_function: Callable[[S], Maybe[T]]) -> Maybe[T]: ... + def is_just(self) -> bool: ... + def is_nothing(self) -> bool: ... + def map(self, function: Callable[[S], T]) -> Maybe[T]: ... + def maybe(self, default_value: T, extraction_function: Callable[[S], T]) -> T: ... + option: Incomplete + def __eq__(self, other): ... + +def Just(value: T) -> Maybe[T]: ... + +Nothing: Maybe[Any] + +class Option(Maybe[T]): ... + +def Some(value: T) -> Option[T]: ... |