Skip to main content

Build Status

tx-functional

Generic functional programming library for Python

The goal of this is

  • Close to Haskell.
  • Work with mypy
  • Pickleable

We choose functions in uncurried form because mypy doesn't support type variable that only appear in return type of a function signature.

classes

Functor

The Functor class is defined in tx.functional.functor. It takes in a _map argument. A functor F is a higer-kinded type * -> *. A functor is defined by a map function

map: (S -> T, F[S]) -> F[T]

Applicative

The Applicative class is defined in tx.functional.applicative. It takes in _map, _pure, and _ap. An applicative F is a functor. An applicative is defined by additional pure and ap functions

pure: S -> F[S]
ap: (F[S -> T], F[S]) -> F[T]

Monad

The Monad class is defined in tx.functional.monad. It takes in _pure and _bind. A monad F is an applicative and a functor. A monad is defined by an additional bind function

bind: (F[S], S -> F[T]) -> F[T]

Traversable

The Traversable class is defined in tx.functional.traversable. It takes in _sequenceA. A traversable F is a functor. A traversable is defined by an additional sequenceA function

sequenceA: F[G[S]] -> G[F[S]]

where G is an applicative

instances

Maybe

Maybe is defined in tx.functional.maybe. It has two constructors, Just and _Nothing. An object Nothing is defined.

We should always use == Nothing to test equality and not is Nothing.

The Functor instance maybe_functor, Applicative instance maybe_applicative, and Monad instance maybe_monad are defined.

Just(1)
Nothing
maybe_applicative.pure(1)
a.bind(lambda x: Nothing)
a.map(lambda x: 1)

Either

Either is defined in tx.functional.either. It has two constructors, Left and Right.

The Functor instance either_functor, Applicative instance either_applicative, and Monad instances either_monad are defined.

Left(1)
Right(1)
either_applicative.pure(1)
a.bind(lambda x: Left(1))
a.map(lambda x: 1)

List

The python builtin types are used. The Functor instance list_functor and Traversable instance list_traversable are defined in tx.functional.list.

The list_traversable instance is a function that takes in an applicative.

list_traversable(maybe_applicative).sequenceA([Just(1)])

Metadata

Release files for tx-functional 0.1.2

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

Source distribution (sdist)

Source distribution for tx-functional 0.1.2
File Size Uploaded Provenance Actions
tx-functional-0.1.2.tar.gz 5.7 kB Without provenance Details for tx-functional-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tx-functional 0.1.2
File Interpreter ABI Platform Actions
tx_functional-0.1.2-py3-none-any.whl Python 3 none any Details for tx_functional-0.1.2-py3-none-any.whl

Total release size: 13.0 kB

Release files / tx-functional-0.1.2.tar.gz

Download URL tx-functional-0.1.2.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c33be62c369ec0f38c5892287ae91b7caf2171308edfe591cf0dc27dd05788ff
BLAKE2b-256 checksum
How to use checksums
cdb112bf76e5076ad137f856c28122678c9ecfadbb10205c0230141fca0e2eb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / tx_functional-0.1.2-py3-none-any.whl

Download URL tx_functional-0.1.2-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2ac68362d71af2fd19f54e23827eca7bda612a22a6b8f03faa521d41e2561b1
BLAKE2b-256 checksum
How to use checksums
ca686633316e395f2293c0a2e3ddb1eb77e9acdaee7a035d18233762d3ab44b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Security for tx-functional 0.1.2

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