annotate json.urs @ 22:8de201d70b91

Implement JSON typeclass for polymorphic variants.
author Edward Z. Yang <ezyang@mit.edu>
date Wed, 02 May 2012 11:47:37 -0400
parents 943410267fad
children 9d6b931fbd13
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
adam@0 7
adam@0 8 val mkJson : a ::: Type -> {ToJson : a -> string,
adam@0 9 FromJson : string -> a * string} -> json a
adam@0 10
adam@0 11 val json_string : json string
adam@0 12 val json_int : json int
adam@0 13 val json_float : json float
adam@0 14 val json_bool : json bool
adam@4 15 val json_option : a ::: Type -> json a -> json (option a)
adam@0 16 val json_list : a ::: Type -> json a -> json (list a)
adam@1 17
adam@1 18 val json_record : ts ::: {Type} -> folder ts -> $(map json ts) -> $(map (fn _ => string) ts) -> json $ts
ezyang@22 19 val json_variant : ts ::: {Type} -> folder ts -> $(map json ts) -> $(map (fn _ => string) ts) -> json (variant ts)
ezyang@22 20
ezyang@22 21 val json_unit : json unit