X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=src%2Fhope_option.erl;h=572162881ec9d85c7d6728ceff7b04c56666758a;hb=b69220d7a75faba9743d5b89b6fa40443cd39eec;hp=180c41687cd7ea5582c8c6901b5fba7dbba8e72e;hpb=4af0774b16181c76d0deedf0911d53409c8f1078;p=hope.git diff --git a/src/hope_option.erl b/src/hope_option.erl index 180c416..5721628 100644 --- a/src/hope_option.erl +++ b/src/hope_option.erl @@ -1,6 +1,6 @@ -module(hope_option). --behavior(hope_monad). +-behavior(hope_gen_monad). -export_type( [ t/1 @@ -14,6 +14,7 @@ , iter/2 , pipe/2 , of_result/1 + , of_undefined/1 ]). @@ -65,3 +66,8 @@ pipe([F|Fs], X) -> t(A). of_result({ok, X}) -> {some, X}; of_result({error, _}) -> none. + +-spec of_undefined(undefined | A) -> + t(A). +of_undefined(undefined) -> none; +of_undefined(X) -> {some, X}.