Mercurial > feed
diff src/ur/feed.ur @ 9:f19beef42ceb
Add tag combinator with given attribute values.
author | Karn Kallio <kkallio@eka> |
---|---|
date | Tue, 31 May 2011 09:21:49 -0430 |
parents | 05a28a77f6fe |
children | edc2b467f818 |
line wrap: on
line diff
--- a/src/ur/feed.ur Sat Mar 19 14:35:11 2011 -0400 +++ b/src/ur/feed.ur Tue May 31 09:21:49 2011 -0430 @@ -47,6 +47,16 @@ | _ => None) (Some {}) fl attrs +fun allPresentE [attrs ::: {Unit}] (fl : folder attrs) (vs : $(mapU (option string) attrs)) (attrs : $(mapU (option string) attrs)) + : option $(mapU string attrs) = + @foldUR2 [option string] [option string] [fn attrs => option $(mapU string attrs)] + (fn [nm ::_] [r ::_] [[nm] ~ r] os os' acc => + case (os, os', acc) of + (Some s, Some s', Some acc) => if s = s' then Some ({nm = s'} ++ acc) else None + | (None, Some s', Some acc) => Some ({nm = s'} ++ acc) + | _ => None) + (Some {}) fl vs attrs + fun tag [attrs ::: {Unit}] (fl : folder attrs) (name : string) (attrs : $(mapU string attrs)) : pattern (tagInternal attrs) {Attrs : $(mapU string attrs), Cdata : option string} = @tagG fl (fn r => @@ -58,6 +68,16 @@ fun tagA [attrs ::: {Unit}] (fl : folder attrs) (name : string) (attrs : $(mapU string attrs)) : pattern (tagInternal attrs) $(mapU string attrs) = @tagG fl (fn r => @allPresent fl r.Attrs) name attrs + +fun tagAV [attrs ::: {Unit}] (fl : folder attrs) (name : string) (attrs : $(mapU (string * option string) attrs)) + : pattern (tagInternal attrs) $(mapU string attrs) = + let + val as = @mp [fn _ => (string * option string)] [fn _ => string] (fn [u] (x, _) => x) fl attrs + val vs = @mp [fn _ => (string * option string)] [fn _ => option string] (fn [u] (_, x) => x) fl attrs + in + @tagG fl (fn r => @allPresentE fl vs r.Attrs) name as + end + fun tagAO [attrs ::: {Unit}] (fl : folder attrs) (name : string) (attrs : $(mapU string attrs)) : pattern (tagInternal attrs) $(mapU (option string) attrs) = @tagG fl (fn r => Some (r.Attrs)) name attrs