Skip to main content

src/fused@sync@promise.erl

-module(fused@sync@promise).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/fused/sync/promise.gleam").
-export([await/2, await_list/1, map/2, map_try/2, rescue/2, resolve/1, tap/2, try_await/2]).

-file("src/fused/sync/promise.gleam", 7).
-spec await(FOD, fun((FOD) -> FOF)) -> FOF.
await(A, B) ->
    B(A).

-file("src/fused/sync/promise.gleam", 11).
-spec await_list(list(FOI)) -> list(FOI).
await_list(Xs) ->
    Xs.

-file("src/fused/sync/promise.gleam", 15).
-spec map(FON, fun((FON) -> FOP)) -> FOP.
map(A, B) ->
    B(A).

-file("src/fused/sync/promise.gleam", 19).
-spec map_try({ok, FOR} | {error, FOS}, fun((FOR) -> {ok, FOW} | {error, FOS})) -> {ok,
        FOW} |
    {error, FOS}.
map_try(Promise, Callback) ->
    gleam@result:'try'(Promise, Callback).

-file("src/fused/sync/promise.gleam", 26).
-spec rescue(FPC, fun((gleam@dynamic:dynamic_()) -> FPC)) -> FPC.
rescue(A, _) ->
    A.

-file("src/fused/sync/promise.gleam", 30).
-spec resolve(FPF) -> FPF.
resolve(A) ->
    A.

-file("src/fused/sync/promise.gleam", 34).
-spec tap(FPH, fun((FPH) -> any())) -> FPH.
tap(Promise, Callback) ->
    Callback(Promise),
    Promise.

-file("src/fused/sync/promise.gleam", 39).
-spec try_await(
    {ok, FPL} | {error, FPM},
    fun((FPL) -> {ok, FPQ} | {error, FPM})
) -> {ok, FPQ} | {error, FPM}.
try_await(Promise, Callback) ->
    gleam@result:'try'(Promise, Callback).