Funx.Monad.Maybe.Just
Mix.install([
{:funx,
git: "https://github.com/JKWA/funx.git",
branch: "main"
}
])
Overview
Represents the Just variant of the Maybe monad, used to model the presence of a value.
A Just wraps a single value and participates in functional composition by propagating the contained value through monadic operations.
This module implements the following protocols:
-
Funx.Monad: Implementsbind/2,map/2, andap/2for monadic composition. -
Funx.Foldable: Providesfold_l/3andfold_r/3to fold over the wrapped value. -
Funx.Filterable: Supports filtering withfilter/2,filter_map/2, andguard/2. -
Funx.Eq: Enables equality checks betweenJustand otherMaybevalues. -
Funx.Ord: Defines ordering behavior betweenJustandNothing.
These protocol implementations allow Just to participate in structured computation, validation, filtering, and comparison within the Maybe context.
Function Examples
import Funx.Monad.Maybe.Just
alias Funx.Monad.Maybe.Just
Functions
pure/1
Creates a new Just value.
The pure/1 function wraps a value in the Just monad, representing the presence of the value.
Examples
pure(5)
Raises
-
ArgumentErrorifnilis provided.
# This will raise an ArgumentError
pure(nil)