ex_optional v0.1.2 ExOptional.Enum
ExOptional.Enum
provides a (minimal) set of Enum
-related functions to work with “Optional” types.
Summary
Functions
Calls Enum.flat_map/2
on the value of a success Optional and returns the mapped Enum
as an Optional, or returns a failed Optional
Calls Enum.map/2
on the value of a success Optional and returns the mapped Enum
as an Optional, or returns a failed Optional
Calls Enum.sort/2
on the value of a success Optional and returns the mapped Enum
as an Optional, or returns a failed Optional
Functions
Calls Enum.flat_map/2
on the value of a success Optional and returns the mapped Enum
as an Optional, or returns a failed Optional.
Calls Enum.map/2
on the value of a success Optional and returns the mapped Enum
as an Optional, or returns a failed Optional.
Examples
iex> ExOptional.map( { :ok, [ 1, 2, 3 ] }, & &1 )
{ :ok, [ 1, 2, 3 ] }
iex> ExOptional.map( { :no, [ 1, 2, 3 ] }, & &1 )
{ :no, nil }
Calls Enum.sort/2
on the value of a success Optional and returns the mapped Enum
as an Optional, or returns a failed Optional.
Examples
iex> ExOptional.sort( { :ok, [3, 1, 2] }, & &1 > &2 )
{ :ok, [ 3, 2, 1 ] }
iex> ExOptional.sort( { :no, [ 3, 1, 2 ] } )
{ :no, nil }