View Source Funx.Monad.Identity (funx v0.1.0)

The Funx.Monad.Identity module represents the identity monad, where values are simply wrapped in a structure and operations are applied directly to those values.

This module implements the following protocols:

  • Funx.Monad: Implements the bind/2, map/2, and ap/2 functions for monadic operations.
  • Funx.Eq: Defines equality checks for Identity values.
  • Funx.Ord: Defines ordering logic for Identity values.
  • String.Chars: Converts an Identity value into a string representation.

Summary

Functions

Extracts the value from an Identity.

Creates a new Identity value by wrapping a given value.

Types

@type t(value) :: %Funx.Monad.Identity{value: value}

Functions

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

Extracts the value from an Identity.

Examples

iex> Funx.Monad.Identity.extract(Funx.Monad.Identity.pure(5))
5
@spec pure(value) :: t(value) when value: term()

Creates a new Identity value by wrapping a given value.

Examples

iex> Funx.Monad.Identity.pure(5)
%Funx.Monad.Identity{value: 5}