-module(gleam@result). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([is_ok/1, is_error/1, map/2, map_error/2, flatten/1, 'try'/2, then/2, unwrap/2, lazy_unwrap/2, unwrap_error/2, unwrap_both/1, nil_error/1, 'or'/2, lazy_or/2, all/1, partition/1, replace/2, replace_error/2, values/1, try_recover/2]). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 20). -spec is_ok({ok, any()} | {error, any()}) -> boolean(). is_ok(Result) -> case Result of {error, _} -> false; {ok, _} -> true end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 41). -spec is_error({ok, any()} | {error, any()}) -> boolean(). is_error(Result) -> case Result of {ok, _} -> false; {error, _} -> true end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 66). -spec map({ok, BJF} | {error, BJG}, fun((BJF) -> BJJ)) -> {ok, BJJ} | {error, BJG}. map(Result, Fun) -> case Result of {ok, X} -> {ok, Fun(X)}; {error, E} -> {error, E} end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 91). -spec map_error({ok, BJM} | {error, BJN}, fun((BJN) -> BJQ)) -> {ok, BJM} | {error, BJQ}. map_error(Result, Fun) -> case Result of {ok, X} -> {ok, X}; {error, Error} -> {error, Fun(Error)} end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 120). -spec flatten({ok, {ok, BJT} | {error, BJU}} | {error, BJU}) -> {ok, BJT} | {error, BJU}. flatten(Result) -> case Result of {ok, X} -> X; {error, Error} -> {error, Error} end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 158). -spec 'try'({ok, BKB} | {error, BKC}, fun((BKB) -> {ok, BKF} | {error, BKC})) -> {ok, BKF} | {error, BKC}. 'try'(Result, Fun) -> case Result of {ok, X} -> Fun(X); {error, E} -> {error, E} end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 170). -spec then({ok, BKK} | {error, BKL}, fun((BKK) -> {ok, BKO} | {error, BKL})) -> {ok, BKO} | {error, BKL}. then(Result, Fun) -> 'try'(Result, Fun). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 192). -spec unwrap({ok, BKT} | {error, any()}, BKT) -> BKT. unwrap(Result, Default) -> case Result of {ok, V} -> V; {error, _} -> Default end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 214). -spec lazy_unwrap({ok, BKX} | {error, any()}, fun(() -> BKX)) -> BKX. lazy_unwrap(Result, Default) -> case Result of {ok, V} -> V; {error, _} -> Default() end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 236). -spec unwrap_error({ok, any()} | {error, BLC}, BLC) -> BLC. unwrap_error(Result, Default) -> case Result of {ok, _} -> Default; {error, E} -> E end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 258). -spec unwrap_both({ok, BLF} | {error, BLF}) -> BLF. unwrap_both(Result) -> case Result of {ok, A} -> A; {error, A@1} -> A@1 end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 279). -spec nil_error({ok, BLI} | {error, any()}) -> {ok, BLI} | {error, nil}. nil_error(Result) -> map_error(Result, fun(_) -> nil end). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 307). -spec 'or'({ok, BLO} | {error, BLP}, {ok, BLO} | {error, BLP}) -> {ok, BLO} | {error, BLP}. 'or'(First, Second) -> case First of {ok, _} -> First; {error, _} -> Second end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 338). -spec lazy_or({ok, BLW} | {error, BLX}, fun(() -> {ok, BLW} | {error, BLX})) -> {ok, BLW} | {error, BLX}. lazy_or(First, Second) -> case First of {ok, _} -> First; {error, _} -> Second() end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 364). -spec all(list({ok, BME} | {error, BMF})) -> {ok, list(BME)} | {error, BMF}. all(Results) -> gleam@list:try_map(Results, fun(X) -> X end). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 384). -spec do_partition(list({ok, BMT} | {error, BMU}), list(BMT), list(BMU)) -> {list(BMT), list(BMU)}. do_partition(Results, Oks, Errors) -> case Results of [] -> {Oks, Errors}; [{ok, A} | Rest] -> do_partition(Rest, [A | Oks], Errors); [{error, E} | Rest@1] -> do_partition(Rest@1, Oks, [E | Errors]) end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 380). -spec partition(list({ok, BMM} | {error, BMN})) -> {list(BMM), list(BMN)}. partition(Results) -> do_partition(Results, [], []). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 406). -spec replace({ok, any()} | {error, BNC}, BNF) -> {ok, BNF} | {error, BNC}. replace(Result, Value) -> case Result of {ok, _} -> {ok, Value}; {error, Error} -> {error, Error} end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 427). -spec replace_error({ok, BNI} | {error, any()}, BNM) -> {ok, BNI} | {error, BNM}. replace_error(Result, Error) -> case Result of {ok, X} -> {ok, X}; {error, _} -> {error, Error} end. -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 443). -spec values(list({ok, BNP} | {error, any()})) -> list(BNP). values(Results) -> gleam@list:filter_map(Results, fun(R) -> R end). -file("/home/pgbiel/GitHub/glistix_stdlib/src/gleam/result.gleam", 474). -spec try_recover( {ok, BNV} | {error, BNW}, fun((BNW) -> {ok, BNV} | {error, BNZ}) ) -> {ok, BNV} | {error, BNZ}. try_recover(Result, Fun) -> case Result of {ok, Value} -> {ok, Value}; {error, Error} -> Fun(Error) end.