annotate record.ur @ 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 6cd839818393
children f55f66c6fdee
rev   line source
adam@11 1 fun numFields [r ::: {Type}] (fl : folder r) (r : $r) : int =
adam@11 2 @fold [fn _ => int] (fn [nm ::_] [u ::_] [r ::_] [[nm] ~ r] acc => acc+1) 0 fl
adam@11 3
adam@10 4 fun mem [a ::: Type] [ns ::: {Unit}] (_ : eq a) (fl : folder ns) (x : a) (r : $(mapU a ns)) : bool =
adam@10 5 @foldUR [a] [fn _ => bool]
adam@10 6 (fn [nm ::_] [r ::_] [[nm] ~ r] y acc =>
adam@10 7 acc || x = y)
adam@10 8 False fl r
adam@12 9
adam@12 10 fun equal [ts ::: {Type}] (eqs : $(map eq ts)) (fl : folder ts) (r1 : $ts) (r2 : $ts) : bool =
adam@18 11 @foldR3 [eq] [ident] [ident] [fn _ => bool]
adam@12 12 (fn [nm ::_] [t ::_] [r ::_] [[nm] ~ r] isEq x y acc =>
adam@12 13 acc && @eq isEq x y)
adam@12 14 True fl eqs r1 r2