fptk is functional programming language extension for hy-lang.
It is implemented as a curated list of FP-related types/classes, functions and macroses, that can be imported into main scope altogether to always have them at your fingertips.
Having high amount of functions available in main context is inspired by Wolfram Language, in which all (yes, ALL) standard functions are always in the main context.
Intended usage of fptk in hy is:
(import fptk *) ; import modules, functions and types/classes
(require fptk *) ; import macrosMain parts of FPTK are:
Basic operations in FP-style:
- Math, logic and checks (most checks in fptk end with "Q": like
intQ,zerolenQ, etc.) - String manipulation and regexes
- Basic IO (functions like
read_fileandfile_existsQ) - Basic benchmarking and debugging
APL-like functions (heavily inspired by funcy lib):
fptk follows funcy approach of providing both generator and list version of most functions (like
mapandlmap). Also, most functions do not mutate data.
- Buffed getters (first, second, last, rest, ...)
- Functional composition, piping, partial application and currying
- Mapping, filtering and partitioning of sequences
Typing:
- Reimport of basic types like
Any,Optional, etc. - Dynamic type checking to an extent that is offered by pydantic
Other quirky things:
- 1-based index variants of basic getters (don't worry, fptk does not force using them in any way)
- Inspired by Haskell:
- macros for lenses library
- Result type (AKA Either monad) that can be type-checked by pydantic
- macros for annotating functions via signatures like
int -> int => float
Tested with:
- Cheetsheet — list of all fptk entities with descriptions
- Basic macros — description of every fptk macro (except lens-related macros)
- Lens related macros — macros that simplify lens definition/application/composition
- Result type — API of fptk implementation of Result type
As of October 2025:
- full documentation is done
- testing suite is written
- some functions require polishing (mostly on adding proper error messsaging)
- edge cases of fptk macros interactions require more testing
Stable release is not yet reached, small API-breaking changes can happen.
The easiest way to install fptk is via command:
pip install git+https://github.com/rmnavr/fptk.git@main