view record.ur @ 11:67b33be5d56a

Record.numFields
author Adam Chlipala <adam@chlipala.net>
date Thu, 03 Feb 2011 14:22:02 -0500
parents 763eb2f2aa5a
children a6730c3cfea7
line wrap: on
line source
fun numFields [r ::: {Type}] (fl : folder r) (r : $r) : int =
    @fold [fn _ => int] (fn [nm ::_] [u ::_] [r ::_] [[nm] ~ r] acc => acc+1) 0 fl

fun mem [a ::: Type] [ns ::: {Unit}] (_ : eq a) (fl : folder ns) (x : a) (r : $(mapU a ns)) : bool =
    @foldUR [a] [fn _ => bool]
     (fn [nm ::_] [r ::_] [[nm] ~ r] y acc =>
         acc || x = y)
     False fl r