awesome-repositories.com
Blog
MCP
awesome-repositories.com

Discover the best open-source repositories with AI-powered search.

ExploreCurated searchesOpen-source alternativesSelf-hosted softwareBlogSitemap
ProjectMCP serverAboutHow we rankPress
LegalPrivacyTerms
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
·
dry-python avatar

dry-python/returns

0
View on GitHub↗
4,310 stars·145 forks·Python·BSD-2-Clause·11 viewsreturns.rtfd.io↗

Returns

Returns is a functional programming library for Python that provides type-safe containers for managing state, error handling, and optionality. It serves as a monadic container library and a type-safe error handling framework, replacing traditional try-catch blocks and null checks with Result and Optional containers to treat exceptions as data.

The project is distinguished by its use of a specialized Mypy static analysis plugin to validate functional pipelines and emulate higher kinded types. It provides mechanisms for isolating side effects through IO containers and offers a framework for type-safe dependency injection that defers the provision of dependencies until the final execution of a computation.

The library covers a broad range of functional primitives, including currying, partial application, and the composition of declarative data pipelines. It supports asynchronous workflow management by wrapping coroutines in containers to chain non-blocking operations and includes utilities for resource lifecycle management and algebraic law verification for custom containers.

Features

  • Python Functional Programming Libraries - Provides a comprehensive toolkit of functional programming primitives and type-safe containers specifically for Python.
  • Monadic Error Handling - Replaces traditional try-catch blocks and null checks with type-safe Result and Optional containers to treat exceptions as data.
  • Monadic Containers - Provides type-safe monadic containers like Result and Optional to manage success, failure, and optionality.
  • Type-Safe Container Wrapping - Encapsulates data within specialized containers to handle nulls, exceptions, and async contexts explicitly.
  • Mypy Plugins - Ships a specialized Mypy plugin to validate higher-kinded types and functional pipelines during static analysis.
  • Optional Value Types - Wraps values to explicitly distinguish between the presence and absence of data to prevent reference errors.
  • Optional Value Extractions - Provides operations to unwrap values from side-effect or optional containers for compatibility with imperative APIs.
  • Container Value Mapping - Applies pure functions to values inside containers via mapping and binding to produce updated containers.
  • Monadic Async Wrapping - Wraps async operations in containers to compose non-blocking computations and handle exceptions without repetitive await statements.
  • Container Value Lifting - Transforms standard functions into operations that can process containerized values within a functional pipeline.
  • Partial Application - Creates new functions by pre-filling a subset of the original function arguments while maintaining type safety.
  • Higher-Kinded Type Simulation - Simulates higher-kinded types to allow generic functions to operate across various container types.
  • Monadic Do Notation - Implements syntactic patterns for sequencing monadic actions to avoid deeply nested function calls while preserving type safety.
  • Do-Notation Type Validation - Enforces type consistency within monadic do-notation blocks through static analysis to prevent mixing container types.
  • Monadic Sequence Wrapping - Sequences multiple container-wrapped values into a single result using a linear syntax that handles wrapping automatically.
  • Container Presence Matching - Employs structural pattern matching to execute different logic paths based on whether a container value is present.
  • Container State Matching - Uses structural pattern matching to execute logic based on whether a value is present or missing in a container.
  • Container Value Matching - Uses structural pattern matching to extract values or handle failure cases from result and optional containers.
  • Function Currying - Transforms functions to accept arguments individually through successive calls.
  • Functional Pipeline Composition - Enables the composition of execution pipelines by chaining multiple operations into a declarative sequence.
  • Result-Based Control Flows - Directs program logic through separate success and failure tracks using explicit result-type containers.
  • Side Effect Marking - Provides mechanisms to explicitly distinguish functions that perform side effects from pure functions.
  • Result Types - Captures the outcome of a function as a typed result container to eliminate uncaught exceptions.
  • Functional Data Pipelines - Provides sequences of operations that transform data using immutable functions and declarative processing logic.
  • Container Computation Chaining - Sequences operations using mapping and binding to flow data through type-safe containers.
  • Container Context Binding - Implements monadic binding to chain computations while preserving the operational state within containers.
  • Function Interface Adaptation - Adapts functions that return containers to accept container inputs, enabling declarative functional composition.
  • Dynamic Error Containers - Uses containers to represent success or failure, enabling a linear data flow without try-catch blocks.
  • Exception Capture - Converts functions that throw exceptions into structured success or failure types to treat errors as data.
  • Pure Functional Cores - Isolates side effects and impure operations from pure business logic to improve testability and architectural clarity.
  • Deferred Dependency Injections - Defers the injection of dependencies until the final execution phase to enable pure function composition.
  • Contextual Function Composition - Chains together pure, impure, or asynchronous functions that depend on external environments while maintaining type safety.
  • Function Composition - Merges two single-argument functions into a single composite operation for predictable data flow.
  • Multiple Container Composition - Sequences operations across multiple type-safe containers using declarative syntax to prevent nested container layers.
  • Optional Value Handling - Wraps optional values in a container to force explicit handling of empty states and replace null checks.
  • Type Conversions - Provides logic for transforming values between different functional container types to ensure type consistency.
  • Value Unwrapping - Extracts the inner value from a container or propagates a specific error if the value is missing.
  • Optional Value Wrapping - Encapsulates potentially null values in Optional containers to replace manual null checks with a chain of operations.
  • Railway Oriented Programming - Implements railway oriented programming patterns to manage separate success and failure tracks.
  • Side Effect Execution Encapsulation - Represents side effects as pure values in containers to separate the definition of an impure operation from its execution.
  • Static Analysis Extensions - Extends the Mypy type checker to provide specialized validation for functional primitives and higher-kinded types.
  • Error Handling - Captures success or failure outcomes in a type-safe container to avoid uncaught exceptions.
  • Functional Type Validation - Uses a specialized Mypy plugin to validate higher-kinded types and functional pipeline consistency.
  • Curried Function Type Validation - Provides static type validation for curried functions and partial applications to ensure type safety across invocation stages.
  • Side Effect Isolation - Isolates impure operations within IO containers to separate side-effecting code from pure business logic.
  • Absence Differentiation - Distinguishes between a present null value and the total absence of a value using distinct container states.
  • Failure Value Mapping - Lifts functions to operate specifically on the failure value of a container while ignoring success.
  • Async Await Patterns - Manages asynchronous computations in containers to handle event loop exceptions and reduce await boilerplate.
  • Contextual Function Lifting - Transforms standard functions into versions that operate on wrapped values for seamless integration into functional pipelines.
  • Custom Functional Containers - Allows the implementation of new type-safe containers by subtyping predefined functional interfaces.
  • Empty State Fallbacks - Triggers a callback function only when a container is empty as a functional alternative to if-else blocks.
  • Functional Interface Extension - Extends existing functional interfaces to build specialized data containers and new functional primitives.
  • Function Chaining - Implements syntactic mechanisms to pass the output of one function as the input to the next in a pipeline.
  • Function Lifting - Provides utilities to transform standard functions into compatible operations for use within functional pipelines.
  • Transparent Async Composition - Wraps coroutines in containers to manipulate asynchronous logic within a synchronous context before execution.
  • Pattern Matching - Uses structural pattern matching to execute different logic based on whether an impure operation succeeded or failed.
  • Predicate Negations - Wraps predicate functions to invert their boolean return value.
  • Pure Function Lifting - Transforms standard functions into compatible operations that can be composed with side-effect containers.
  • Algebraic Law Specifications - Allows the formal specification of algebraic laws to ensure custom functional containers exhibit predictable behavior.
  • Async Error Compositions - Wraps asynchronous functions in containers that capture exceptions as failure states to prevent program crashes.
  • Async Computation Wrappers - Wraps asynchronous operations in a protective layer to simplify composition and prevent unexpected exceptions.
  • Async Exception Containers - Wraps async operations in containers to prevent unhandled exceptions from crashing the event loop.
  • Async Result Captures - Wraps asynchronous functions to catch exceptions and return them as type-safe result containers.
  • Asynchronous Container Wrapping - Wraps coroutines in containers to allow non-blocking workflow composition without repetitive await statements.
  • Asynchronous Operation Chaining - Links future results and handles exceptions in asynchronous call chains without repetitive wait statements.
  • Compositional Transformation Pipelines - Chains sequential data transformations into a single executable pipeline to decouple logic from execution.
  • Containerized Result Returns - Allows returning a specific container type based on a boolean expression as a declarative alternative to if-else statements.
  • Containerized Function Application - Executes a function wrapped in a container against a value wrapped in another container, maintaining functional purity.
  • Dependency-Injected Contexts - Provides mechanisms for sharing type-checked configuration state across a call chain using dependency injection.
  • Failure to Success Lifting - Lifts functions that return containers to act on the failed state of another container to restore success.
  • Error Type Compositions - Merges different error types from multiple operations into a single union type when chaining computations.
  • Error Type Transformations - Lifts functions to operate on the error or failure state of a container without affecting the success value.
  • Failure Recovery Strategies - Transforms failed computations into success states or provides fallback values via result container operations.
  • Exception-to-Result Adapters - Transforms exception-throwing patterns into return-value-based error handling using result containers.
  • Type-Safe Equality Enforcements - Provides compile-time enforcement of type-safe equality comparisons to prevent unintended comparisons between unrelated types.
  • Success and Failure Partitioning - Separates a collection of containers into two distinct lists based on successful values and failures.
  • Success State Detection - Provides mechanisms to check if a result container represents a successful operation.
  • Branch Matching Functions - Executes specific logic based on whether a container is in a success or failure state to replace imperative branching.
  • Imperative-to-Functional Bridges - Provides mechanisms to wrap the return values of standard imperative functions into functional containers.
  • Explicit Dependency-Injection Wiring - Passes dependencies into functions using a type-safe, explicit mechanism to improve architectural readability.
  • Iterable Container Aggregation - Combines collections of containers into a single container and fails the entire operation if any single element fails.
  • Iterable Container Processing - Executes declarative loops over collections of containers to accumulate results while maintaining functional context.
  • Asynchronous Pipelines - Models asynchronous interactions in a synchronous context to chain functions without requiring asynchronous callers.
  • Monadic Async Bindings - Binds asynchronous functions to monadic containers to manage non-blocking computations.
  • Result Fallback Extractions - Retrieves the inner value from a result container or provides a specified fallback upon failure.
  • Container Flattening - Merges multiple layers of nested containers into a single level to simplify access to the wrapped value.
  • Optional Return Wrappers - Provides decorators that automatically wrap the output of functions returning optional types into type-safe containers.
  • IO Value Extractions - Allows extracting inner values from IO containers to maintain compatibility with non-functional imperative frameworks.
  • Resource Acquisition and Release - Binds resource acquisition steps to guaranteed release actions to ensure the safe management of files and connections.
  • Resource Lifecycle Management - Guarantees the acquisition and release of stateful resources to ensure proper cleanup after operations.
  • Side Effect Discarding - Implements side-effect execution that can discard results to maintain the flow of the original value pipeline.
  • Error Track Verifications - Verifies that failure paths in result containers are explicitly handled to prevent unhandled exceptions in pipelines.
  • Exception-to-Container Conversions - Captures errors in a container instead of raising them to handle exceptions as data.
  • Typed Error Management - Wraps dependency-dependent functions in containers that explicitly manage failure states using result types.
  • Algebraic Law Verifications - Generates automated test cases to validate that custom functional containers adhere to formal algebraic laws.
  • Result State Validators - Provides utilities for checking the success or failure status of a result container.
  • Functional Programming - Implements type-safe monads and functional composition.
  • Functional Utility Libraries - Facilitates safe, typed, and meaningful functional return values.
  • General Utilities - Tools for type-safe and functional error handling.
  • Type Extensions - Typed, safe functional programming primitives.

Star history

Star history chart for dry-python/returnsStar history chart for dry-python/returns

AI search

Explore more awesome repositories

Describe what you need in plain English — the AI ranks thousands of curated open-source projects by relevance.

Start searching with AI

Open-source alternatives to Returns

Similar open-source projects, ranked by how many features they share with Returns.
  • gcanti/fp-tsgcanti avatar

    gcanti/fp-ts

    11,523View on GitHub↗

    fp-ts is a TypeScript library that brings pure functional programming patterns to the language through algebraic data types, type class abstractions, and composable combinators. It provides foundational data types like Option for optional values, Either for typed error handling, and Task for lazy asynchronous computations, all designed to make invalid states unrepresentable and side effects explicit. The library is built on category theory concepts, offering type classes such as Functor, Applicative, Monad, Semigroup, and Monoid with lawful instances for common data structures. The library di

    TypeScriptalgebraic-data-typesfunctional-programmingtypescript
    View on GitHub↗11,523
  • vkhorikov/csharpfunctionalextensionsvkhorikov avatar

    vkhorikov/CSharpFunctionalExtensions

    2,777View on GitHub↗

    CSharpFunctionalExtensions is a functional programming library for C# that provides a framework of monadic containers, pipeline orchestration tools, and immutable domain object patterns. It implements the result pattern to handle operation success and failure as values, reducing the reliance on exceptions for control flow. The library enables railway-oriented programming by chaining multiple operations into sequences that execute only upon the success of previous steps. It provides specialized wrappers for optional and result types to minimize null checks and nested conditional logic, alongsi

    C#csharpentityfunctional-programming
    View on GitHub↗2,777
  • louthy/language-extlouthy avatar

    louthy/language-ext

    7,057View on GitHub↗

    language-ext is a functional programming framework for C# that provides a suite of immutable data structures and monadic types. It enables the implementation of pure functional programming patterns, utilizing containers to manage side effects, optional values, and error handling. The library is distinguished by its advanced concurrency and state management tools, including a software transactional memory system and lock-free atomic references. It also provides specialized utilities for distributed systems, such as vector clocks for causality tracking and deterministic data conflict resolution

    C#
    View on GitHub↗7,057
  • dry-rb/dry-typesdry-rb avatar

    dry-rb/dry-types

    899View on GitHub↗

    This library provides a type system for Ruby applications, offering a framework for defining, validating, and coercing data structures. It serves as a foundation for maintaining data integrity by ensuring that input values conform to established schemas and constraints before they are processed by application logic. The system distinguishes itself through a functional approach to data transformation and validation. It utilizes an immutable registry for type definitions and employs algebraic operators to compose complex, nested schemas from smaller, reusable components. By wrapping validation

    Rubycoercionconstraintsdry-rb
    View on GitHub↗899
See all 30 alternatives to Returns→

Frequently asked questions

What does dry-python/returns do?

Returns is a functional programming library for Python that provides type-safe containers for managing state, error handling, and optionality. It serves as a monadic container library and a type-safe error handling framework, replacing traditional try-catch blocks and null checks with Result and Optional containers to treat exceptions as data.

What are the main features of dry-python/returns?

The main features of dry-python/returns are: Python Functional Programming Libraries, Monadic Error Handling, Monadic Containers, Type-Safe Container Wrapping, Mypy Plugins, Optional Value Types, Optional Value Extractions, Container Value Mapping.

What are some open-source alternatives to dry-python/returns?

Open-source alternatives to dry-python/returns include: gcanti/fp-ts — fp-ts is a TypeScript library that brings pure functional programming patterns to the language through algebraic data… vkhorikov/csharpfunctionalextensions — CSharpFunctionalExtensions is a functional programming library for C# that provides a framework of monadic containers,… louthy/language-ext — language-ext is a functional programming framework for C# that provides a suite of immutable data structures and… dry-rb/dry-types — This library provides a type system for Ruby applications, offering a framework for defining, validating, and coercing… pytoolz/toolz — Toolz is a Python library that implements functional programming utilities for iterable transformation, dictionary… purescript/purescript — PureScript is a statically typed, purely functional programming language that compiles to JavaScript. It is designed…