Mercurial > meta
annotate json.urs @ 30:4e673b535434
Optimizing JSON generation
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Thu, 04 Dec 2014 19:52:51 -0500 |
parents | 9d6b931fbd13 |
children |
rev | line source |
---|---|
adam@5 | 1 (** The JSON text-based serialization format *) |
adam@5 | 2 |
adam@0 | 3 class json |
adam@0 | 4 |
adam@0 | 5 val toJson : a ::: Type -> json a -> a -> string |
adam@0 | 6 val fromJson : a ::: Type -> json a -> string -> a |
ezyang@23 | 7 val fromJson' : a ::: Type -> json a -> string -> a * string |
adam@0 | 8 |
adam@0 | 9 val mkJson : a ::: Type -> {ToJson : a -> string, |
adam@0 | 10 FromJson : string -> a * string} -> json a |
adam@0 | 11 |
adam@0 | 12 val json_string : json string |
adam@0 | 13 val json_int : json int |
adam@0 | 14 val json_float : json float |
adam@0 | 15 val json_bool : json bool |
adam@4 | 16 val json_option : a ::: Type -> json a -> json (option a) |
adam@0 | 17 val json_list : a ::: Type -> json a -> json (list a) |
adam@1 | 18 |
adam@1 | 19 val json_record : ts ::: {Type} -> folder ts -> $(map json ts) -> $(map (fn _ => string) ts) -> json $ts |
ezyang@22 | 20 val json_variant : ts ::: {Type} -> folder ts -> $(map json ts) -> $(map (fn _ => string) ts) -> json (variant ts) |
ezyang@22 | 21 |
ezyang@22 | 22 val json_unit : json unit |
ezyang@23 | 23 |
ezyang@23 | 24 functor Recursive (M : sig |
ezyang@23 | 25 con t :: Type -> Type |
ezyang@23 | 26 val json_t : a ::: Type -> json a -> json (t a) |
ezyang@23 | 27 end) : sig |
ezyang@23 | 28 datatype r = Rec of M.t r |
ezyang@23 | 29 |
ezyang@23 | 30 val json_r : json r |
ezyang@23 | 31 end |