Skip to main content

Pycategories

master pipeline master coverage

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

Metadata

Release files for pycategories 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycategories 1.2.0
File Size Uploaded Provenance Actions
pycategories-1.2.0.tar.gz 16.1 kB Without provenance Details for pycategories-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pycategories 1.2.0
File Interpreter ABI Platform Actions
pycategories-1.2.0-py3-none-any.whl Python 3 none any Details for pycategories-1.2.0-py3-none-any.whl

Total release size: 29.3 kB

Release files / pycategories-1.2.0.tar.gz

Download URL pycategories-1.2.0.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bd70ecb5e94e7659e564ea153f0c7673291dc37c526c246800fc08d6c5378099
BLAKE2b-256 checksum
How to use checksums
c2e9f31b58d91383c5b5d13bc1b9d02fbc730f5a121ce82962c3b61f9aad83ed
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / pycategories-1.2.0-py3-none-any.whl

Download URL pycategories-1.2.0-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2a472a7127de0a5f0fad7ce6bc95c5320c5394c86bf976d997911347694f803
BLAKE2b-256 checksum
How to use checksums
8bc7cfc55b1fc7c07b2ace1cee2e4ca4cec0e33205428f01b0a374bc94b6e081
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for pycategories 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page