Browse files

Add format product

  • Loading branch information...
1 parent 17d045c commit 4a915e47a52519fa6e85e7558193f40ed85af0b4 @VictorNicollet committed Jul 13, 2012
Showing with 13 additions and 0 deletions.
  1. +11 −0 src/fmt.ml
  2. +2 −0 src/fmt.mli
View
11 src/fmt.ml
@@ -38,6 +38,17 @@ let real_value = function
| Json.Null -> None
| other -> Some other
+let ( * ) a b = {
+ to_json = (fun (xa,xb) -> Json.Array [ a.to_json xa ; b.to_json xb ]) ;
+ of_json = (function
+ | Json.Array [ ja ; jb ] -> begin
+ match a.of_json ja, b.of_json jb with
+ | Some xa, Some xb -> Some (xa,xb)
+ | _ , _ -> None
+ end
+ | _ -> None)
+}
+
module type FMT = sig
type t
val of_json : Json.t -> t
View
2 src/fmt.mli
@@ -13,6 +13,8 @@ val protect : ?save:(Json.t -> Json.t) -> (Json.t -> 'a) -> Json.t -> 'a option
val real_value : Json.t -> Json.t option
+val ( * ) : 'a t -> 'b t -> ('a * 'b) t
+
module type FMT = sig
type t
val of_json : Json.t -> t

0 comments on commit 4a915e4

Please sign in to comment.