https://github.com/vickumar1981/pyeffects
Handle side-effects in Python like a boss. Implements functional types for Either, Option, Try, and Future.
https://github.com/vickumar1981/pyeffects
either either-monad future future-monad futures hacktoberfest hacktoberfest-accepted hacktoberfest2023 monad monads option option-monad option-type python python27 python3 try try-catch try-monad
Last synced: 4 months ago
JSON representation
Handle side-effects in Python like a boss. Implements functional types for Either, Option, Try, and Future.
- Host: GitHub
- URL: https://github.com/vickumar1981/pyeffects
- Owner: vickumar1981
- License: other
- Created: 2020-03-27T07:43:46.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-15T19:06:44.000Z (10 months ago)
- Last Synced: 2025-01-16T17:26:13.769Z (4 months ago)
- Topics: either, either-monad, future, future-monad, futures, hacktoberfest, hacktoberfest-accepted, hacktoberfest2023, monad, monads, option, option-monad, option-type, python, python27, python3, try, try-catch, try-monad
- Language: Python
- Homepage:
- Size: 369 KB
- Stars: 32
- Watchers: 3
- Forks: 6
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README

# pyEffects
[](https://badge.fury.io/py/pyeffects) [](https://pyeffects.readthedocs.io/en/latest/?badge=latest)
[](https://github.com/vickumar1981/pyeffects/blob/master/LICENSE)Monads for Python. Side-effect explicitly.
Handle your side-effects in Python like a boss. Implements functional types for Either, Option, Try, and Future.
For more detailed information, please refer to the [API Documentation](https://pyeffects.readthedocs.io/en/latest/ "API Documentation").
---
### 1. Install`pip install pyeffects`
---
### 2. Using Option
```python
>>> from pyeffects.Option import *
>>> val = Some(5).map(lambda v: v * v)
>>> val
Some(25)
>>> val.is_defined()
True
>>> val.get()
25```
---
### 3. Using Try
```python
>>> from pyeffects.Try import *
>>> val = Success(5).map(lambda v: v * v)
>>> val
Success(25)
>>> val.is_success()
True
>>> val.get()
25```
---
### 4. Using Either
```python
>>> from pyeffects.Either import *
>>> val = Right(5).map(lambda v: v * v)
>>> val
Right(25)
>>> val.is_right()
True
>>> val.right()
25
```---
### 5. Using Future
```python
>>> from pyeffects.Future import *
>>> val = Future.of(5).map(lambda v: v * v)
>>> val
Future(Success(25))
>>> val.on_complete(lambda v: print(v))
Success(25)
>>> val.get()
25
```---
### 6. Reporting an IssuePlease report any issues or bugs to the [Github issues page](https://github.com/vickumar1981/pyeffects/issues).
---
### 7. LicenseThis project is licensed under the [Apache 2 License](https://github.com/vickumar1981/pyeffects/blob/master/LICENSE).