home
/
code
/
hope.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #2 from puzza007/property-testing
[hope.git]
/
src
/
hope_option.erl
diff --git
a/src/hope_option.erl
b/src/hope_option.erl
index
92636c9
..
c461d04
100644
(file)
--- a/
src/hope_option.erl
+++ b/
src/hope_option.erl
@@
-1,5
+1,6
@@
-module(hope_option).
-module(hope_option).
+
-export_type(
[ t/1
]).
-export_type(
[ t/1
]).
@@
-17,16
+18,20
@@
.
.
+-spec put(A, fun((A) -> boolean())) ->
+ t(A).
put(X, F) ->
case F(X)
of true -> {some, X}
; false -> none
end.
put(X, F) ->
case F(X)
of true -> {some, X}
; false -> none
end.
-
+-spec get(t(A), Default :: A) ->
+ A.
get({some, X}, _) -> X;
get(none , Y) -> Y.
get({some, X}, _) -> X;
get(none , Y) -> Y.
-
+-spec map(t(A), fun((A) -> (B))) ->
+ t(B).
map({some, X}, F) -> {some, F(X)};
map(none , _) -> none.
map({some, X}, F) -> {some, F(X)};
map(none , _) -> none.
This page took
0.018566 seconds
and
4
git commands to generate.