diff src/ur/feed.urs @ 11:43c3fbd8527a

Add variant of children allowing specification of optional matches.
author Karn Kallio <kkallio@eka>
date Thu, 23 Jun 2011 23:40:29 -0430
parents edc2b467f818
children f641cfcd5153
line wrap: on
line diff
--- a/src/ur/feed.urs	Thu Jun 09 12:59:27 2011 -0430
+++ b/src/ur/feed.urs	Thu Jun 23 23:40:29 2011 -0430
@@ -53,6 +53,15 @@
                 -> pattern (childrenInternal parentI (map fst children)) (parent * $(map (fn (i, d) => option d) children))
 (* A version of [children] where each child pattern need not be matched *)
 
+datatype required t = Required of t | Optional of t
+(* Used for marking items as required or optional. *)
+
+val childrenO' : parentI ::: Type -> parent ::: Type -> children ::: {(Type * Type)}
+                 -> pattern parentI parent -> $(map (fn (i, d) => required (pattern i d)) children) -> folder children
+                 -> pattern (childrenInternal parentI (map fst children)) (parent * $(map (fn (i, d) => option d) children))
+(* A version of [children] where the caller marks each child pattern
+ * as either required or optional. *)
+
 con treeInternal :: Type -> Type -> Type
 
 val tree : parentI ::: Type -> parent ::: Type -> childI ::: Type -> child ::: Type