View Source Funx.Monad.Either.Left (funx v0.1.0)

Represents the Left variant of the Either monad, used to model an error or failure.

This module implements the following protocols:

  • Funx.Eq: Defines equality checks between Left and other Either values.
  • Funx.Foldable: Provides fold_l/3 and fold_r/3 to handle folding for Left values.
  • Funx.Monad: Implements the bind/2, map/2, and ap/2 functions for monadic operations.
  • Funx.Ord: Defines ordering logic for Left and Right values.

The Left monad propagates the wrapped error through operations without executing the success logic.

Summary

Functions

Creates a new Left value.

Types

@type t(value) :: %Funx.Monad.Either.Left{left: value}

Functions

@spec pure(value) :: t(value) when value: term()

Creates a new Left value.

The pure/1 function wraps a value in the Left monad, representing an error or failure.

Examples

iex> Funx.Monad.Either.Left.pure("error")
%Funx.Monad.Either.Left{left: "error"}