X-Git-Url: https://git.xandkar.net/?p=hope.git;a=blobdiff_plain;f=src%2Fhope_option.erl;h=d820b7bc90b2d10ba719508c8f4182c08497c678;hp=c461d04d1b70d3bbd292e954aa21c55eb4921c5e;hb=27a4f25fb636bbff0f8085d66e433125dc5fe17d;hpb=b79afea06befb5309f4a3f0388e587e17c484b83 diff --git a/src/hope_option.erl b/src/hope_option.erl index c461d04..d820b7b 100644 --- a/src/hope_option.erl +++ b/src/hope_option.erl @@ -9,6 +9,7 @@ [ put/2 , get/2 , map/2 + , iter/2 ]). @@ -35,3 +36,8 @@ get(none , Y) -> Y. t(B). map({some, X}, F) -> {some, F(X)}; map(none , _) -> none. + +-spec iter(t(A), fun((A) -> (ok))) -> + ok. +iter({some, X}, F) -> ok = F(X); +iter(none , _) -> ok.