The strict, multi-paradigm framework enabling pure functional patterns in Python.
Project description
🦉 Stolas
The strict, multi-paradigm framework enabling pure functional patterns in Python.
Wisdom through pure functional patterns — Safe separation of data and behavior with monadic safety, immutability, and type-safe composition.
🦉 The S-T-O-L-A-S Framework
Struct
Fast, immutable data classes with @struct and polymorphic @trait for behavior dispatch.
Types
Safe monadic containers: Result, Option, Validated, Effect, Many
Operands
Powerful decorators: @ops, @cases, @binary, @as_result, concurrent()
Logic
Ergonomic functional combinators: get, at, where, apply, _ placeholder, and 20+ utilities
A-S
(Reserved for future expansion)
🦉 Key Features
- ✅ Strictness: Runtime type checking +
__slots__for memory efficiency - ✅ Sealed ADTs:
@casesdecorator with pattern matching and monadic compatibility - ✅ Functional Composition: Pipeline chaining with
>> - ✅ Async Concurrency: Parallel workflows with
concurrent() - ✅ Polymorphism: Trait-based dispatch for decoupled behavior
- ✅ Type Safety:
mypy --strict-clean core, plus a bundled mypy plugin for@struct/@cases(see Typing Model)
🦉 Installation
pip install stolas
🦉 Quick Example
from stolas.struct import struct
from stolas.types import Many
from stolas.operand import binary, as_result, ops
from stolas.logic import where, apply, _
# Immutable data
@struct
class User:
id: int
name: str
email: str
# Safe, curried operations
@ops(binary, as_result)
def divide(a: int, b: int) -> float:
return a / b
# Functional pipelines with placeholder
users = Many([
User(id=1, name="Alice", email="alice@example.com"),
User(id=2, name="Bob", email="bob@example.com"),
])
result = users >> where(_.id > 1) >> apply(_.name) # Many(["Bob"])
# Monadic safety
divide(10)(2) # Ok(5.0)
divide(10)(0) # Error(ZeroDivisionError(...))
🦉 Documentation
For detailed documentation, see the docs/ directory:
- Struct & Trait - Polymorphism (
@trait) and immutable data (@struct) - Monadic Types -
Result,Option,Validated,Effect,AsyncEffect,Many - Control - Effectful flow combinators:
bracket,RetryPolicy/retry, andtimeout - Operands - Decorators
@cases, theas_*safe combinators (as_result/as_option/as_validated/as_many/as_effect), and Concurrency - Logic Reference - Combinators and Placeholder (
_) - Validation - Generic field validators (
rule,matches,all_of, ...) and@struct __validators__ - Interop - Zero-dependency interop with pydantic / SQLAlchemy / msgspec via
stolas.serde,variant_from_dict, and@struct(open=True) - Typing Model - What is precisely typed, what is intentionally opaque, the bundled mypy plugin, and how to enable it in your own config
🦉 Testing
# Run tests
python -m pytest tests/
# Type checking
mypy src/stolas --strict
Status: 🦉 1113 tests passing • 100% coverage • mypy --strict-clean core + bundled plugin (the _ placeholder and dual-mode >> are intentionally opaque — see Typing Model)
🦉 License
MIT License
Project details
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 stolas-0.2.0.tar.gz.
File metadata
- Download URL: stolas-0.2.0.tar.gz
- Upload date:
- Size: 41.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d464ff4ca08b27922df671dafdaadb3598681afc546a26b2c5a065cacdc2190
|
|
| MD5 |
0036431d06dc316cf6580a7e6cae7b78
|
|
| BLAKE2b-256 |
d7112cf7e0e6463043ffa7cf941b16dfd055ffa267fb53dacd30b2caa81924ba
|
File details
Details for the file stolas-0.2.0-py3-none-any.whl.
File metadata
- Download URL: stolas-0.2.0-py3-none-any.whl
- Upload date:
- Size: 56.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
700cdbf179dcd8aeaead73196953f2d17ce72a85875709cf6dcb76af2b1bd819
|
|
| MD5 |
a7058880c4b00a1130d89fa2308b4ed8
|
|
| BLAKE2b-256 |
2dd0ced5d424c8fe14ba31f104026db3b920fa46a02f08e95959fcb4ccad8f4f
|