comparison src/ur/feed.ur @ 5:2717458d8951

Splitting fetching and traversal into separate functions
author Adam Chlipala <adam@chlipala.net>
date Thu, 13 Jan 2011 10:02:37 -0500
parents af95d9d73eb5
children e0bae488825c
comparison
equal deleted inserted replaced
4:af95d9d73eb5 5:2717458d8951
175 | Some cstate => 175 | Some cstate =>
176 case child.Finished cstate of 176 case child.Finished cstate of
177 None => None 177 None => None
178 | Some (cdata, _) => Some ((pdata, cdata), True)} 178 | Some (cdata, _) => Some ((pdata, cdata), True)}
179 179
180 fun app [internal ::: Type] [data ::: Type] (p : pattern internal data) (f : data -> transaction {}) (url : string) : transaction {} = 180 type document = string
181
182 val fetch = FeedFfi.fetch
183
184 fun app [internal ::: Type] [data ::: Type] (p : pattern internal data) (f : data -> transaction {}) (doc : document) : transaction {} =
181 let 185 let
182 fun recur xml state = 186 fun recur xml state =
183 case String.seek xml #"<" of 187 case String.seek xml #"<" of
184 None => return () 188 None => return ()
185 | Some xml => 189 | Some xml =>
303 | Some (data, cont) => 307 | Some (data, cont) =>
304 f data; 308 f data;
305 recur xml (if cont then state else p.Initial) 309 recur xml (if cont then state else p.Initial)
306 end 310 end
307 in 311 in
308 xml <- FeedFfi.fetch url; 312 recur doc p.Initial
309 recur xml p.Initial
310 end 313 end