Monads for Python. Side-effect explicitly.
Project description
pyEffects
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.
8. License
This project is licensed under the Apache 2 License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyeffects-1.0.3.tar.gz
(9.8 kB
view hashes)
Built Distribution
Close
Hashes for pyeffects-1.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0a137494c30b334ba9fdc2ee5898d4a0f1061130faad8f59c48b1fdbc943a03 |
|
MD5 | 43cddcaf272a658f3ca6f78ccb036ac6 |
|
BLAKE2b-256 | f7b0da44711727a2d242839423ef0e0fd6cf11e03a9bee6a5d34ca0026049cb2 |