-- Application of the deep selection patterns -- Michael and Sergio -- Mon Apr 18 15:47:00 PDT 2011 -- Retrieve all the e-mail addresses from an HTML file import SetFunctions import HTML import HtmlParser fname = "syllabus.html" main = do elems <- readHtmlFile fname --printValues (set1 anyEmailAddress elems) printValues (set1 eAddress (head elems)) -- DEEP SELECTORS -- element in a list withElem :: a -> [a] withElem e = e:unknown ? unknown:withElem e -- html element in html document withHtmlElem :: HtmlExp -> HtmlExp withHtmlElem helem = helem ? HtmlStruct unknown unknown (withElem (withHtmlElem helem)) -- find some e-mail address in an hyml document eAddress :: HtmlExp -> String eAddress (withHtmlElem (HtmlStruct _ (withElem ("href","mailto:"++name)) _)) = name