diff options
author | Adam Chlipala <adam@chlipala.net> | 2016-08-26 19:26:49 -0400 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2016-08-26 19:26:49 -0400 |
commit | f0c60c01bb078da639efd3aaf33bc2f0ff996169 (patch) | |
tree | 13331d77af7df44f203eec317cc093625de46b96 /lib/ur/json.urs | |
parent | 7b2b2db168cb6b9a027981800b45e3bbb7425e33 (diff) |
Import Json module from old Meta library (thanks to Edward Z. Yang for code contributions)
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 |