Skip to main content

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

stateless-0.1.0.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

stateless-0.1.0-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page