Encapsulation and decorators made easy.
Project description
The encapsulation library
Introducing: the From class.
For maintainable data pipelines.
Adds new syntactic sugar to python!
Installation
pip install -e encapsulation
Getting started
Get started by
from encapsulation.base import Maybe
Maybe("a") + "b" # outputs <Maybe val=(ab)>
Maybe(None) * 2 # outputs <Nothing val=(None)>
Easy to use decorators that elevate functions to return wrapped values instead:
from encapsulation.base import Maybe, to
def add1(n: int):
return n + 1
@to(Maybe)
def (s: int):
return s
test(1).bind(add1).effect(print) # prints '[2]'
You can chain computations using compose(). For example
from encapsulation.base import Just, compose
@to(Just[int])
def add2(s: int):
return s
compose(Just(1), add2, add2) # equals Just(5)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file encapsulation-0.2.0.tar.gz.
File metadata
- Download URL: encapsulation-0.2.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5e0ae1d6e55c972864def707214c9d79daf5e867007202039b6ea6ec4f52d28
|
|
| MD5 |
b31c2a067639229e9788fbc2acc67a67
|
|
| BLAKE2b-256 |
1e23b4218b1cf1efdbb1a7690fec95fad16c3be0caaae4819239b65d959a7f86
|
File details
Details for the file encapsulation-0.2.0-py3-none-any.whl.
File metadata
- Download URL: encapsulation-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01dcff7cf7f6ec102ef0d77a91d37e9188362357671563f61487408b114d07fb
|
|
| MD5 |
b41088cf1cf5eca218e629b8ab4b00bc
|
|
| BLAKE2b-256 |
515855dec16c3a89043d2ec7d4a5fb4a17911e3a201e9c810d4b36dc72f5c909
|