No project description provided
Project description
stateless
Statically typed, purely functional algebraic effects for Python.
Concepts
Actions, Effects and Handlers
stateless
is a purely functional effect system, that enables you to program without side-effects, even when writing code that needs to do IO, such as reading or writing from files, accessing the network etc.
When programming with stateless
you will describe your programs side-effects using the stateless.Effect
type. This is in fact just a type alias, roughly equivalent to:
from typing import Generator, Never, Any
from stateless import Action
Effect = Generator[stateless.Action | Exception, Never, Any]
(In reality its a bit more complicated. But for now, think of effects in stateless
like this)
In words: effects are generators of stateless.Action
instances or exceptions, that can return anything. A stateless.Action
instance in turn, describes a side-effect you want your program to perform.
Lets begin with a simple example:
from typing import Never
from stateless.console import Input, Print
from stateless import Effect
def say_hello() -> Effect[Print, Never, None]:
name = yield from Input("What is your name?")
yield from Print(f"Hello, {name}!")
stateless.console.Print
is a subtype of stateless.Action
Error Handling
TODO
Scheduling and Retrying
TODO
Async Actions
TODO
Background
Similar Projects
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
Hashes for stateless-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a32fdf2db0ff7df2d0fd4d16a4b85584308933a9ce39e303b54f5ed1e52bf97 |
|
MD5 | 84ba36c81dc77b0c960b0d6a1af0816e |
|
BLAKE2b-256 | c0f2a498d8b96f2e09bdeb1a38a7f5ee4a50835b4dc4cc852ac075d64ddea6e9 |