pyeffects

Monads for Python. Side-effect explicitly.


Keywords
either, either-monad, future, future-monad, futures, hacktoberfest, hacktoberfest-accepted, hacktoberfest2021, monad, monads, option, option-monad, option-type, python, python27, python3, try, try-catch, try-monad
License
Apache-2.0
Install
pip install pyeffects==1.0.5

Documentation

Logo

pyEffects

Build Status PyPI version Documentation Status 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.


1. Install

pip install pyeffects


2. Using Option

>>> 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

>>> 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

>>> 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

>>> 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 Issue

Please report any issues or bugs to the Github issues page.


7. License

This project is licensed under the Apache 2 License.