Add specs.
authorSiraaj Khandkar <siraaj@khandkar.net>
Tue, 15 Jul 2014 00:48:04 +0000 (20:48 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Tue, 15 Jul 2014 00:48:04 +0000 (20:48 -0400)
src/hope_option.erl
src/hope_result.erl

index 622c06d..c461d04 100644 (file)
     .
 
 
+-spec put(A, fun((A) -> boolean())) ->
+    t(A).
 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.
 
+-spec map(t(A), fun((A) -> (B))) ->
+    t(B).
 map({some, X}, F) -> {some, F(X)};
 map(none     , _) -> none.
index a40629a..5d0ea7e 100644 (file)
     .
 
 
+-spec pipe([F], X) ->
+    t(Ok, Error)
+    when X     :: any()
+       , Ok    :: any()
+       , Error :: any()
+       , F     :: fun((X) -> t(Ok, Error))
+       .
 pipe([]    , X) -> X;
 pipe([F|Fs], X) ->
     case F(X)
This page took 0.022517 seconds and 4 git commands to generate.