-- Search Google and retrieve the results into some-- nicer data structure. This is an exercise in-- munging the HTML output of Google.

-- A number of possible functions are demonstrated,-- to show some different ways of going about the task,-- only one is really needed.

-- Personally, I favor the 2nd version, selectGoogleResultsToXML. -- I think this is a good demonstration of a case where the -- ordinary Haskell combinators are clearer than the special -- Arrow syntax.

-- There isn't any help, from Google, in picking out the results,-- so I've poked around and came up with this:-- look for -- <div id="res"> ... <h2> ... <a onmousedown="..." ...>-- and the results will be contained within the anchor.

-- This last example introduces some new syntax,-- namely -<<. According to the GHC Arrow docs,-- you cannot use locally bound variables on the-- left-hand side of -<. In brief, the -<< syntax is-- a variation which permits this, while introducing-- a dependency on the ArrowApply class.

-- The reason why 'selem' is on the LHS in the-- first place is because, if you check the type-- of 'selem', you will see that it is already-- in the Arrow (so to speak). Injecting it-- with 'returnA' would simply create an extra-- layer of Arrow that is not wanted.

-- Since 'selem' is not processing anything, the RHS -- of -<< in this case is simply ().

-- XML version[xml]<- runX (parseHTML body >>>-- At the top of a document is a hidden "root" node-- which encompasses all the top-level siblings. root [][selectGoogleResultsToXML]>>> writeDocumentToString [(a_indent,v_1)])putStrLn xml