Implementation of some concepts from category theory
Project description
Pycategories is a Python 3 library that implements ideas from category theory, such as monoids, functors, and monads. It provides a Haskell-influenced interface for defining instances of those typeclasses and defines several right out of the box, for example the Maybe monad:
>>> from categories import apply >>> from categories.maybe import Just, Nothing >>> f = Just(lambda x: x ** 2) >>> x = Just(17) >>> apply(f, x) Just(289) >>> apply(f, Nothing()) Nothing
Or to define your own instance of a typeclass:
>>> from categories import mappend, mempty, monoid
>>> monoid.instance(dict, lambda: {}, lambda a, b: dict(**a, **b))
>>> mappend({'foo': 'bar'}, {'rhu': 'barb'})
{'foo': 'bar', 'rhu': 'barb'}
Installation
pip install pycategories
To clone the repo and install dependencies for development:
git clone https://gitlab.com/danielhones/pycategories cd pycategories pip install -e .[dev]
Support and Contributing
License
Pycategories is licensed under the MIT License
Documentation
Documentation is available at pycategories.readthedocs.io
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 pycategories-1.2.0.tar.gz.
File metadata
- Download URL: pycategories-1.2.0.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.4 CPython/3.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd70ecb5e94e7659e564ea153f0c7673291dc37c526c246800fc08d6c5378099
|
|
| MD5 |
7e7da474f240fd51fda2b8322fbe8126
|
|
| BLAKE2b-256 |
c2e9f31b58d91383c5b5d13bc1b9d02fbc730f5a121ce82962c3b61f9aad83ed
|
File details
Details for the file pycategories-1.2.0-py3-none-any.whl.
File metadata
- Download URL: pycategories-1.2.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.4 CPython/3.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2a472a7127de0a5f0fad7ce6bc95c5320c5394c86bf976d997911347694f803
|
|
| MD5 |
5e90e05cef69e98c4ed8f964f75255b3
|
|
| BLAKE2b-256 |
8bc7cfc55b1fc7c07b2ace1cee2e4ca4cec0e33205428f01b0a374bc94b6e081
|