camlspotter avatar camlspotter committed 9a755b8

update of meta_conv

Comments (0)

Files changed (2)

 open Tiny_json
 open Json
 
+open Meta_conv.Types
+open Meta_conv.Types.Error
+open Meta_conv.Internal
+
 module Encode = struct
   let int n       = Number (float n)
   let int32 n     = Number (Int32.to_float n)
     | None -> Null
     | Some v -> f v
   let unit ()     = Null
- 
+
   let tuple ts       = Array ts
   let variant tag = function
     | [] -> String tag
 
 let errorf fmt = Printf.ksprintf (fun s -> raise (Failure s)) fmt
 
-module Decode = Meta_conv.Conv.Make_Decode_Adrs(struct
+module Decode = Meta_conv.Internal.Make_Decode_Adrs(struct
   type t = Json.t
   let tuple = function 
     | Array ts -> ts
-    | _ -> errorf "Array expected for array"
+    | _ -> errorf "Array expected for tuple"
 
   let variant = function 
     | String tag -> tag, [] 
 end)
 
 open Printf
-open Meta_conv.Conv
 
-type 'a decoder = ('a, Json.t) Meta_conv.Conv.decoder
-exception Error of Json.t error
+type 'a decoder = ('a, Json.t) Meta_conv.Types.Decoder.t
+exception Error of Json.t Error.t
 
 let errorf v adrs fmt = 
   kprintf (fun s -> `Error (Primitive_decoding_failure s, v, adrs)) fmt
   | Null -> true
   | _ -> false) d
 
-let lazy_t_of_json f = generic_lazy_t_of f
-
-
+let lazy_t_of_json f = generic_lazy_t_of (fun e -> raise (Error e)) f
+let mc_lazy_t_of_json = generic_mc_lazy_t_of 

lib/json_conv.mli

 open Tiny_json
-open Meta_conv.Conv
+open Meta_conv.Types
 
 module Encode : sig
   val tuple : Json.t list -> Json.t
   val record : Json.t * Address.t -> (string * (Json.t * Address.t)) list
 end
 
-type 'a decoder = ('a, Json.t) Meta_conv.Conv.decoder
-exception Error of Json.t error
+type 'a decoder = ('a, Json.t) Decoder.t
+exception Error of Json.t Error.t
 
 val string_of_json    : string decoder
 val char_of_json      : char decoder
 val array_of_json     : 'a decoder -> 'a array decoder
 val option_of_json    : 'a decoder -> 'a option decoder
 val lazy_t_of_json    : 'a decoder -> 'a lazy_t decoder
+val mc_lazy_t_of_json : 'a decoder -> ('a, Json.t) mc_lazy_t decoder
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.