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.
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.get()
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().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.1.tar.gz
(9.1 kB
view hashes)
Built Distribution
Close
Hashes for pyeffects-1.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 984c830690e82fd714de4fedc6d095120a72b747f396e3304202b666793156ac |
|
MD5 | 5b5654476e31dc080a3d66fc3ce764d2 |
|
BLAKE2b-256 | c1dab445c2ddd57a82355db3f779333e4c3481b4d4fb90cb03ba73a17ef2b5dd |