Mercurial > urweb
changeset 1481:3061d1bf4b2d
recToList
author | Robin Green <greenrd@greenrd.org> |
---|---|
date | Mon, 27 Jun 2011 21:36:32 +0100 |
parents | aa0c6382aa57 |
children | 8314f1a309e7 |
files | lib/ur/list.ur lib/ur/list.urs |
diffstat | 2 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/ur/list.ur Tue Jun 28 11:55:57 2011 +0100 +++ b/lib/ur/list.ur Mon Jun 27 21:36:32 2011 +0100 @@ -353,3 +353,7 @@ case assoc x ls of None => (x, y) :: ls | Some _ => ls + +fun recToList [a ::: Type] [r ::: {Unit}] (fl : folder r) + = @foldUR [a] [fn _ => list a] (fn [nm ::_] [rest ::_] [[nm] ~ rest] x xs => + x :: xs) [] fl
--- a/lib/ur/list.urs Tue Jun 28 11:55:57 2011 +0100 +++ b/lib/ur/list.urs Mon Jun 27 21:36:32 2011 +0100 @@ -79,3 +79,7 @@ val assoc : a ::: Type -> b ::: Type -> eq a -> a -> t (a * b) -> option b val assocAdd : a ::: Type -> b ::: Type -> eq a -> a -> b -> t (a * b) -> t (a * b) + +(** Converting records to lists *) + +val recToList : a ::: Type -> r ::: {Unit} -> folder r -> $(mapU a r) -> t a