From 2497062cedae903b4f8dd00b82da386b0e4f9b62 Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Thu, 11 Dec 2014 23:48:16 -0500 Subject: [PATCH] Add hope_option:of_result/1 --- src/hope.app.src | 2 +- src/hope_option.erl | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hope.app.src b/src/hope.app.src index 89c71bb..7167180 100644 --- a/src/hope.app.src +++ b/src/hope.app.src @@ -1,7 +1,7 @@ {application, hope, [ {description, "Higher Order Programming in Erlang"}, - {vsn, "1.2.0"}, + {vsn, "1.3.0"}, {registered, []}, {applications, [ kernel, 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. -- 2.20.1