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.0.tar.gz
(8.8 kB
view details)
Built Distribution
File details
Details for the file pyeffects-1.0.0.tar.gz
.
File metadata
- Download URL: pyeffects-1.0.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb2d9172a604175be5b4e9c182e63609f7123725ede158c11f1a580fe303cbad |
|
MD5 | edd79dbc41d1c1d33369df2e5e6f94b2 |
|
BLAKE2b-256 | 7afb765c6cda2b9d9a7f20abaa000edf496497f19229cc4282024b83586e6755 |
File details
Details for the file pyeffects-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pyeffects-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c38bbedca470eaa09da7737450ee2fb297318c05881c2ca811c8126dc8aa386 |
|
MD5 | e6bc55e73f40042017cec4004037a88e |
|
BLAKE2b-256 | e555da510deb3f187b09b55956f6c9ec86eeb84f394c3f4fde9a8c61c33465fa |