X-Git-Url: https://git.xandkar.net/?p=hope.git;a=blobdiff_plain;f=src%2Fhope_option.erl;h=529158d06f04c1642292947af1ac57551c39a4f4;hp=180c41687cd7ea5582c8c6901b5fba7dbba8e72e;hb=f2e1fffc2e9ce505ae1891a2251ae2036ed13422;hpb=781f182fe399d95fc144ba3b47112e803ba6af6e diff --git a/src/hope_option.erl b/src/hope_option.erl index 180c416..529158d 100644 --- a/src/hope_option.erl +++ b/src/hope_option.erl @@ -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}.