Mercurial > feed
comparison 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 |
comparison
equal
deleted
inserted
replaced
10:edc2b467f818 | 11:43c3fbd8527a |
---|---|
51 val childrenO : parentI ::: Type -> parent ::: Type -> children ::: {(Type * Type)} | 51 val childrenO : parentI ::: Type -> parent ::: Type -> children ::: {(Type * Type)} |
52 -> pattern parentI parent -> $(map (fn (i, d) => pattern i d) children) -> folder children | 52 -> pattern parentI parent -> $(map (fn (i, d) => pattern i d) children) -> folder children |
53 -> pattern (childrenInternal parentI (map fst children)) (parent * $(map (fn (i, d) => option d) children)) | 53 -> pattern (childrenInternal parentI (map fst children)) (parent * $(map (fn (i, d) => option d) children)) |
54 (* A version of [children] where each child pattern need not be matched *) | 54 (* A version of [children] where each child pattern need not be matched *) |
55 | 55 |
56 datatype required t = Required of t | Optional of t | |
57 (* Used for marking items as required or optional. *) | |
58 | |
59 val childrenO' : parentI ::: Type -> parent ::: Type -> children ::: {(Type * Type)} | |
60 -> pattern parentI parent -> $(map (fn (i, d) => required (pattern i d)) children) -> folder children | |
61 -> pattern (childrenInternal parentI (map fst children)) (parent * $(map (fn (i, d) => option d) children)) | |
62 (* A version of [children] where the caller marks each child pattern | |
63 * as either required or optional. *) | |
64 | |
56 con treeInternal :: Type -> Type -> Type | 65 con treeInternal :: Type -> Type -> Type |
57 | 66 |
58 val tree : parentI ::: Type -> parent ::: Type -> childI ::: Type -> child ::: Type | 67 val tree : parentI ::: Type -> parent ::: Type -> childI ::: Type -> child ::: Type |
59 -> pattern parentI parent -> pattern childI child | 68 -> pattern parentI parent -> pattern childI child |
60 -> pattern (treeInternal parentI childI) (parent * child) | 69 -> pattern (treeInternal parentI childI) (parent * child) |