Packages

A porting of some parts of fp-ts to Gleam

Current section

Files

Jump to
fp_gl src fp_gl@ord.erl
Raw

src/fp_gl@ord.erl

-module(fp_gl@ord).
-compile(no_auto_import).
-export([min/1, max/1, get_semigroup/0, get_monoid/0]).
-spec min(fp_gl@models:ord(EPD)) -> fun((EPD, EPD) -> EPD).
min(O) ->
fun(First, Second) -> case (erlang:element(2, O))(First, Second) of
eq ->
First;
lt ->
First;
gt ->
Second
end end.
-spec max(fp_gl@models:ord(EPG)) -> fun((EPG, EPG) -> EPG).
max(O) ->
fun(First, Second) -> case (erlang:element(2, O))(First, Second) of
eq ->
First;
lt ->
Second;
gt ->
First
end end.
-spec get_semigroup() -> fp_gl@models:semigroup(fp_gl@models:ord(any())).
get_semigroup() ->
{semigroup,
fun(First, Second) ->
{ord,
fun(A, B) ->
First_res = (erlang:element(2, First))(A, B),
case First_res of
eq ->
(erlang:element(2, Second))(A, B);
_@1 ->
First_res
end
end}
end}.
-spec get_monoid() -> fp_gl@models:monoid(fp_gl@models:ord(any())).
get_monoid() ->
{monoid, erlang:element(2, get_semigroup()), {ord, fun(_, _) -> eq end}}.