diff options
Diffstat (limited to 'lib/ur/json.urs')
-rw-r--r-- | lib/ur/json.urs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/ur/json.urs b/lib/ur/json.urs new file mode 100644 index 00000000..b4bd6350 --- /dev/null +++ b/lib/ur/json.urs @@ -0,0 +1,31 @@ +(** The JSON text-based serialization format *) + +class json + +val toJson : a ::: Type -> json a -> a -> string +val fromJson : a ::: Type -> json a -> string -> a +val fromJson' : a ::: Type -> json a -> string -> a * string + +val mkJson : a ::: Type -> {ToJson : a -> string, + FromJson : string -> a * string} -> json a + +val json_string : json string +val json_int : json int +val json_float : json float +val json_bool : json bool +val json_option : a ::: Type -> json a -> json (option a) +val json_list : a ::: Type -> json a -> json (list a) + +val json_record : ts ::: {Type} -> folder ts -> $(map json ts) -> $(map (fn _ => string) ts) -> json $ts +val json_variant : ts ::: {Type} -> folder ts -> $(map json ts) -> $(map (fn _ => string) ts) -> json (variant ts) + +val json_unit : json unit + +functor Recursive (M : sig + con t :: Type -> Type + val json_t : a ::: Type -> json a -> json (t a) + end) : sig + datatype r = Rec of M.t r + + val json_r : json r +end |