View Source Funx.Monad.Maybe.Just (funx v0.1.0)
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/2
for monadic composition.Funx.Foldable
: Providesfold_l/3
andfold_r/3
to fold over the wrapped value.Funx.Filterable
: Supports filtering withfilter/2
,filter_map/2
, andguard/2
.Funx.Eq
: Enables equality checks betweenJust
and otherMaybe
values.Funx.Ord
: Defines ordering behavior betweenJust
andNothing
.
These protocol implementations allow Just
to participate in structured computation, validation, filtering, and comparison within the Maybe
context.
Summary
Functions
Creates a new Just
value.
Types
@type t(value) :: %Funx.Monad.Maybe.Just{value: value}
Functions
Creates a new Just
value.
The pure/1
function wraps a value in the Just
monad, representing the presence of the value.
Examples
iex> Funx.Monad.Maybe.Just.pure(5)
%Funx.Monad.Maybe.Just{value: 5}
Raises
ArgumentError
ifnil
is provided.iex> Funx.Monad.Maybe.Just.pure(nil) ** (ArgumentError) Cannot wrap nil in a Just