Funx.Monad.Identity (funx v0.8.4)

View Source

Run in Livebook

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.

Functions

  • pure/1: Wraps a value in the Identity monad.
  • extract/1: Extracts the wrapped value from an Identity.

Protocols

This module implements the following protocols:

Summary

Functions

Extracts the value from an Identity.

Creates a new Identity value by wrapping a given value.

Types

t(value)

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

Functions

extract(identity)

@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

lift_eq(custom_eq)

@spec lift_eq(Funx.Eq.eq_map()) :: Funx.Eq.eq_map()

lift_ord(custom_ord)

@spec lift_ord(Funx.Ord.ord_t()) :: Funx.Ord.ord_map()

pure(value)

@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}