-module(gbr@shared@try). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src\\gbr\\shared\\try.gleam"). -export([new/1, unwrap/1, map_error/2, map/2, wrap/3, context/2, with_context/2, print_line/2, print/2]). -export_type(['try'/1]). -type 'try'(FKV) :: {'try', FKV, list(binary())}. -file("src\\gbr\\shared\\try.gleam", 31). -spec try_new(FLN) -> 'try'(FLN). try_new(Error) -> {'try', Error, []}. -file("src\\gbr\\shared\\try.gleam", 24). -spec new({ok, FLH} | {error, FLI}) -> {ok, FLH} | {error, 'try'(FLI)}. new(Result) -> case Result of {ok, T} -> {ok, T}; {error, _} -> gleam@result:map_error(Result, fun try_new/1) end. -file("src\\gbr\\shared\\try.gleam", 42). -spec try_unwrap('try'(FLV)) -> FLV. try_unwrap(Try) -> erlang:element(2, Try). -file("src\\gbr\\shared\\try.gleam", 35). -spec unwrap({ok, FLP} | {error, 'try'(FLQ)}) -> {ok, FLP} | {error, FLQ}. unwrap(Try) -> case Try of {ok, T} -> {ok, T}; {error, _} -> gleam@result:map_error(Try, fun try_unwrap/1) end. -file("src\\gbr\\shared\\try.gleam", 53). -spec try_map_error('try'(FOU), fun((FOU) -> FOW)) -> 'try'(FOW). try_map_error(Try, Mapper) -> {'try', Mapper(erlang:element(2, Try)), erlang:element(3, Try)}. -file("src\\gbr\\shared\\try.gleam", 46). -spec map_error({ok, FLY} | {error, 'try'(FLZ)}, fun((FLZ) -> FMC)) -> {ok, FLY} | {error, 'try'(FMC)}. map_error(Try, Mapper) -> gleam@result:map_error( Try, fun(_capture) -> try_map_error(_capture, Mapper) end ). -file("src\\gbr\\shared\\try.gleam", 57). -spec map({ok, FMI} | {error, 'try'(FMJ)}, fun((FMI) -> FMM)) -> {ok, FMM} | {error, 'try'(FMJ)}. map(Try, Parser) -> gleam@result:map(Try, Parser). -file("src\\gbr\\shared\\try.gleam", 61). -spec wrap( {ok, FMP} | {error, 'try'(FMQ)}, fun(({ok, FMP} | {error, FMQ}) -> {ok, FMV} | {error, FMW}), fun(('try'(FMQ)) -> binary()) ) -> {ok, FMV} | {error, 'try'(FMW)}. wrap(Try, Parser, Describe) -> Stack = case Try of {ok, _} -> []; {error, E} -> [Describe(E) | erlang:element(3, E)] end, _pipe = Try, _pipe@1 = unwrap(_pipe), _pipe@2 = Parser(_pipe@1), _pipe@3 = new(_pipe@2), gleam@result:map_error( _pipe@3, fun(T) -> {'try', erlang:element(2, T), Stack} end ). -file("src\\gbr\\shared\\try.gleam", 88). -spec stack_add('try'(FQB), binary()) -> 'try'(FQB). stack_add(Error, Context) -> {'try', erlang:element(2, Error), [Context | erlang:element(3, Error)]}. -file("src\\gbr\\shared\\try.gleam", 83). -spec context({ok, FNE} | {error, 'try'(FNF)}, binary()) -> {ok, FNE} | {error, 'try'(FNF)}. context(Try, Context) -> Add = fun(Error) -> stack_add(Error, Context) end, gleam@result:map_error(Try, Add). -file("src\\gbr\\shared\\try.gleam", 78). -spec with_context(binary(), fun(() -> {ok, FQL} | {error, 'try'(FQM)})) -> {ok, FQL} | {error, 'try'(FQM)}. with_context(Error_context, Next) -> _pipe = Next(), context(_pipe, Error_context). -file("src\\gbr\\shared\\try.gleam", 122). -spec stack_to_lines(list(binary())) -> list(binary()). stack_to_lines(Stack) -> _pipe = Stack, lists:reverse(_pipe). -file("src\\gbr\\shared\\try.gleam", 100). -spec pretty_print_with_joins( 'try'(FNR), binary(), binary(), fun((FNR) -> binary()) ) -> binary(). pretty_print_with_joins(Try, Join_current, Join_stack, To_s) -> Current = To_s(try_unwrap(Try)), Stack = <>, Stack@1 = case erlang:element(3, Try) of [] -> <<""/utf8>>; _ -> Stack end, <>. -file("src\\gbr\\shared\\try.gleam", 92). -spec print_line('try'(FNM), fun((FNM) -> binary())) -> binary(). print_line(Try, Describe) -> pretty_print_with_joins(Try, <<" < "/utf8>>, <<" < "/utf8>>, Describe). -file("src\\gbr\\shared\\try.gleam", 96). -spec print('try'(FNO), fun((FNO) -> binary())) -> binary(). print(Try, Describe) -> pretty_print_with_joins( Try, <<"\n\nstack:\n "/utf8>>, <<"\n "/utf8>>, Describe ).