changeset 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
files src/ur/feed.ur src/ur/feed.urs
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/ur/feed.ur	Tue Jan 11 18:04:15 2011 -0500
+++ b/src/ur/feed.ur	Thu Jan 13 10:02:37 2011 -0500
@@ -177,7 +177,11 @@
                                    None => None
                                  | Some (cdata, _) => Some ((pdata, cdata), True)}
 
-fun app [internal ::: Type] [data ::: Type] (p : pattern internal data) (f : data -> transaction {}) (url : string) : transaction {} =
+type document = string
+
+val fetch = FeedFfi.fetch
+
+fun app [internal ::: Type] [data ::: Type] (p : pattern internal data) (f : data -> transaction {}) (doc : document) : transaction {} =
     let
         fun recur xml state =
             case String.seek xml #"<" of
@@ -305,6 +309,5 @@
                                      recur xml (if cont then state else p.Initial)
                         end
     in
-        xml <- FeedFfi.fetch url;
-        recur xml p.Initial
+        recur doc p.Initial
     end
--- a/src/ur/feed.urs	Tue Jan 11 18:04:15 2011 -0500
+++ b/src/ur/feed.urs	Thu Jan 13 10:02:37 2011 -0500
@@ -23,4 +23,7 @@
            -> pattern parentI parent -> pattern childI child
            -> pattern (treeInternal parentI childI) (parent * child)
 
-val app : internal ::: Type -> data ::: Type -> pattern internal data -> (data -> transaction {}) -> string -> transaction {}
+type document
+
+val fetch : string (* url *) -> transaction document
+val app : internal ::: Type -> data ::: Type -> pattern internal data -> (data -> transaction {}) -> document -> transaction {}