composition operator

added composition operator to utils module
This commit is contained in:
Eitan Chatav 2016-11-04 12:22:22 -07:00
parent 438281f1e1
commit b8b93651af
3 changed files with 6 additions and 2 deletions

View File

@ -434,8 +434,8 @@ let addr_encoding =
let public_key_encoding = let public_key_encoding =
let open Data_encoding in let open Data_encoding in
conv conv
(fun public_key -> MBytes.to_string (Crypto_box.of_public_key public_key)) (MBytes.to_string << Crypto_box.of_public_key)
(fun str -> Crypto_box.to_public_key (MBytes.of_string str)) (Crypto_box.to_public_key << MBytes.of_string)
string string
let peers_file_encoding = let peers_file_encoding =

View File

@ -121,3 +121,5 @@ let rec remove_elem_from_list nb = function
| [] -> [] | [] -> []
| l when nb <= 0 -> l | l when nb <= 0 -> l
| _ :: tl -> remove_elem_from_list (nb - 1) tl | _ :: tl -> remove_elem_from_list (nb - 1) tl
let (<<) g f = fun a -> g (f a)

View File

@ -38,3 +38,5 @@ val remove_elem_from_list: int -> 'a list -> 'a list
val filter_map: ('a -> 'b option) -> 'a list -> 'b list val filter_map: ('a -> 'b option) -> 'a list -> 'b list
(** Compose functions from right to left. *)
val (<<) : ('b -> 'c) -> ('a -> 'b) -> 'a -> 'c