FuPy: Functional Programming in Python, for Education
Overview
- Documentation
- For some examples, see demo.py.
Python offers (limited) support for functional programming:
- functions are first-class citizens;
- functions can take functions as arguments and can return functions
- lambda expressions for anonymous functions
FuPy aims to overcome some limitations, by adding:
- basic types and type constructors
Emptytype without valuesUnittype with valueunitEither[A, B](disjoint sum) typeBoth[A, B](product) type (tuple)Func[A, B]function space type
- function composition and other function combinators
@for head-to-tail composition, also written as ⚬&for split, also written as △|for case, also written as ▽*for product (functor over product/tuple type), also written as ⨯
+for sum (functor over sum/Either type), also written as +**for iterated composition, also written with a superscript^for functorial exponentiation
- auto (un)packing of arguments in case of functions with no/multiple arguments
- predefined common functions:
id_,const,left,right,guard,first,secondcurry,uncurry,flip,ap,compose,split,case_,fplus,ftimes,fpower,fpower_left
- operator sections
- lazy expressions (suspended computations)
- printable function and lambda expressions
- evaluation tracing
- inductive and co-inductive types
Functor,fmapFix,fixcata(catamorphisms, folds)ana(anamorphims, unfolds)
Main classes:
Func, for composable, printable, and traceable functions with auto-(un)packing of arguments.OperatorSection, for operator sectionsLazy, for lazy expressions.
Not intended for industrial use:
- there are performance penalties in terms of memory and execution overhead
Notes:
- Type hints do not all verify (but it works). The Python type system is too limited (we need Higher-Kinded Types, HKTs).
- Binding strength of function combinators are as applied by Python, doesn't correspond to the theory.
Future work
- Applicatives and monads
Installation
pip install FuPy
Development (for developers)
- Build:
python -m build
- Test:
pytest
- Build documentation:
In
docs/make clean make html
- Upload to PyPI:
twine upload dist/*
Authors and acknowledgment
- Tom Verhoeff (Eindhoven University of Technology, Netherlands)
License
Project status
- Under development, but already usable
- Documentation:
- incomplete
- Sphinx version still has issues
- Test cases: incomplete
- Functionality:
- functions only print in mixed Math/Python notation
- level of detail in tracing cannot be selected
- limited form of laziness
- Issues
Metadata
Release files for FuPy 0.9.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fupy-0.9.1.tar.gz | 28.4 kB | Without provenance | Details for fupy-0.9.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fupy-0.9.1-py3-none-any.whl | Python 3 | none | any | Details for fupy-0.9.1-py3-none-any.whl |
Total release size: 58.6 kB
Release files / fupy-0.9.1.tar.gz
| Download URL | fupy-0.9.1.tar.gz |
|---|---|
| Size | 28.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
919def89619a98abd3cad1afeee6e8c3aa7908b8d4040f81c0767facb7a971ac
|
|
BLAKE2b-256 checksum How to use checksums |
49f910e841e3ea220cc2d66fc8affd9a62f985d6620b994a0c13dd9eeb5a2cdd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Release files / fupy-0.9.1-py3-none-any.whl
| Download URL | fupy-0.9.1-py3-none-any.whl |
|---|---|
| Size | 30.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a519a90347c1f06c1f3e075ef52e4c965e2849704e7ab1c3262908eae4a5e0da
|
|
BLAKE2b-256 checksum How to use checksums |
55abc1e7753438bff96fbc16ac2a4ab21c4978dc915a780f84152a24ce981164
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Security for FuPy 0.9.1
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.