Advertisement
Guest User

Untitled

a guest
Jun 8th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.41 KB | None | 0 0
  1. module type Convert = sig
  2.     type t
  3.     val to_string : t -> string
  4.     val of_string : string -> t
  5. end
  6.  
  7. type (_,_) compose =
  8.     | Cons : (module Convert with type t = 'a) * ('b, 'c) compose -> ('a -> 'b, 'c) compose
  9.     | Nil  : ('c, 'c) compose
  10.  
  11. let rec serialize : type f. (f, unit) compose -> f -> string = function
  12.     | Nil -> fun () -> ""
  13.     | Cons ((module C), rest) -> fun x -> (C.to_string x) ^ (serialize rest)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement