--- Example for a Curry program which extracts email addresses --- from a HTML page. --- Since this program requires a few libraries, it must be executed --- as follows: --- --- > cypm add -d setfunctions # add dependencies --- > cypm add -d html2 --- > cypm install # install required dependencies --- > pakcs :l EmailsInHtml :eval main :quit import Control.SetFunctions import HTML.Base import HTML.Parser -- HTML documents with a given element: withHtmlElem :: BaseHtml -> BaseHtml withHtmlElem helem = helem ? BaseStruct _ _ (withElem (withHtmlElem helem)) -- lists with a given element: withElem :: a -> [a] withElem e = e:_ ? _:withElem e -- extract some email address in an HTML document: anyEmailAddress :: BaseHtml -> String anyEmailAddress (withHtmlElem (BaseStruct _ (withElem ("href","mailto:" ++ name)) _)) = name -- collect and print all email addresses in an HTML document: main :: IO () main = do elems <- readHtmlFile "syllabus.html" printValues (set1 anyEmailAddress (head elems))