Skip to main content


Project description


Eff is a Python library to work with algebraic effects.

Algbraic effects are all side-effects of a piece of code, like reading a user input, writing a text on the screen, doing network requests, reading a file etc. Eff allows to easily handle such effects making the code cleaner and testing easier.


  • Easy to understand. You don't need to read long scientific papers to understand how to use the library and what it does.
  • Easy to integrate. If you decided to add a logger into a function, changes will be minimal, no need to pass the logger down through the whole call stack.
  • Fast. The classic approach for handling algebraic effects is using coroutines or exceptions. This library uses global shared state instead which doesn't require to unwrap the whole call stack at runtime.
  • Type-safe. Effect handlers container is just a class. Annotate effect handlers type to make their usage type-safe.


python3 -m pip install --user eff


from io import StringIO
from typing import Callable

import eff

class Eff(eff.ects):
    show: Callable

# Use global effects manager in a function.
def greet(username: str) -> None:'Hello, {username}!')

# Provide actual side-effects handlers
# for the project prod entry point.
def main() -> None:
    with Eff(show=print):

# Mock side-effects in tests.
def test_greet() -> None:
    stream = StringIO()
    with Eff(show=stream.write):
    assert == 'Hello, World!'

if __name__ == '__main__':

Further reading

You don't have to read it but it's a good reading for better understanding of the motivation behind the library.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for eff, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size eff-1.0.0.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View
Filename, size eff-1.0.0-py3-none-any.whl (4.1 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page