No project description provided
Project description
dataclass-applicative --- treating dataclasses like containers
This package provides functions for manipulating dataclasses as containers.
Documentation
The documentation is hosted on ReadTheDocs, and the source code for that documentation is available here.
Quick start
Given a dataclass,
>>> from dataclasses import dataclass
>>> from dataclass_applicative import amap, fmap, gather, pure, names, values
>>> @dataclass
... class F:
... x: object
... y: object
... z: object
we can list its fields;
>>> list(names(F))
['x', 'y', 'z']
list its values;
>>> list(values(F(1, 2, 3)))
[1, 2, 3]
default-construct new instances;
>>> pure(F, 1)
F(x=1, y=1, z=1)
apply a function to those values;
>>> fmap(str, F(1, 2, 3))
F(x='1', y='2', z='3')
or apply functions stored in one object to values stored in another;
>>> amap(F(str, lambda _: 999, lambda z: z + 1), F(1, 2, 3))
F(x='1', y=999, z=4)
and gather all attributes from many instances into tuples in a new object:
>>> gather(F(1, 2, 3), F(10, 11, 12), F(3, 2, 1), F(0, 0, 0))
F(x=(1, 10, 3, 0), y=(2, 11, 2, 0), z=(3, 12, 1, 0))
Project details
Release history Release notifications | RSS feed
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 dataclass-applicative-0.1.0.tar.gz.
File metadata
- Download URL: dataclass-applicative-0.1.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0923029a4d59b46bd8e10dbc964434b13038d62a937a0fb73a6cb86c9cb733df
|
|
| MD5 |
ea6ed41cae99e0ce625ba4df52d0c931
|
|
| BLAKE2b-256 |
f73f87a4e667daa293594c54513550aa3362125118d9adea94d5c033d720c50b
|
File details
Details for the file dataclass_applicative-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dataclass_applicative-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12db21484acc0a06c77279da5a0d9a34488af560c0b3f13b7b0b23782290569a
|
|
| MD5 |
7deb6686bd3d7977f1dfb037d37979a5
|
|
| BLAKE2b-256 |
79a4b7ba35575197857f4f7a6898735a668b45967baa13df8ee68dd23a0a2792
|