comparison src/ur/feed.ur @ 21:7275f59cab61

tagAOR and a Reddit example of using it
author Adam Chlipala <adam@chlipala.net>
date Sat, 29 Sep 2012 10:30:00 -0400
parents f641cfcd5153
children
comparison
equal deleted inserted replaced
20:dd5b333a7960 21:7275f59cab61
78 @tagG fl (fn r => @allPresentE fl vs r.Attrs) name as 78 @tagG fl (fn r => @allPresentE fl vs r.Attrs) name as
79 end 79 end
80 80
81 fun tagAO [attrs ::: {Unit}] (fl : folder attrs) (name : string) (attrs : $(mapU string attrs)) 81 fun tagAO [attrs ::: {Unit}] (fl : folder attrs) (name : string) (attrs : $(mapU string attrs))
82 : pattern (tagInternal attrs) $(mapU (option string) attrs) = 82 : pattern (tagInternal attrs) $(mapU (option string) attrs) =
83 @tagG fl (fn r => Some (r.Attrs)) name attrs 83 @tagG fl (fn r => Some r.Attrs) name attrs
84
85 fun tagAOR [optional ::: {Unit}] [required ::: {Unit}] [optional ~ required]
86 (ofl : folder optional) (rfl : folder required)
87 (name : string) (required : $(mapU string required)) (optional : $(mapU string optional))
88 : pattern (tagInternal (optional ++ required)) $(mapU string required ++ mapU (option string) optional) =
89 @tagG (@Folder.concat ! ofl rfl)
90 (fn r => case @allPresent rfl (r.Attrs --- mapU (option string) optional) of
91 None => None
92 | Some req => Some (r.Attrs --- mapU (option string) required ++ req))
93 name (required ++ optional)
84 94
85 fun tagC (name : string) : pattern (tagInternal []) string = 95 fun tagC (name : string) : pattern (tagInternal []) string =
86 tagG (fn r => r.Cdata) name {} 96 tagG (fn r => r.Cdata) name {}
87 97
88 datatype status a = Initial | Pending of a | Matched of a 98 datatype status a = Initial | Pending of a | Matched of a