X-Git-Url: https://git.xandkar.net/?p=hope.git;a=blobdiff_plain;f=src%2Fhope_option.erl;h=ab6eab775af29f9d6cae2fccdd638cbb25200402;hp=d820b7bc90b2d10ba719508c8f4182c08497c678;hb=2497062cedae903b4f8dd00b82da386b0e4f9b62;hpb=27a4f25fb636bbff0f8085d66e433125dc5fe17d diff --git a/src/hope_option.erl b/src/hope_option.erl index d820b7b..ab6eab7 100644 --- a/src/hope_option.erl +++ b/src/hope_option.erl @@ -10,6 +10,7 @@ , get/2 , map/2 , iter/2 + , of_result/1 ]). @@ -41,3 +42,8 @@ map(none , _) -> none. ok. iter({some, X}, F) -> ok = F(X); iter(none , _) -> ok. + +-spec of_result(hope_result:t(A, _B)) -> + t(A). +of_result({ok, X}) -> {some, X}; +of_result({error, _}) -> none.