module TagSoup.Sample where import Text.HTML.TagSoup import Network.HTTP import Data.Char import Data.List import Data.Maybe import System.IO openItem :: String -> IO String openItem x | "http://" `isPrefixOf` x = getResponseBody =<< simpleHTTP (getRequest x) | otherwise = readFile x grab :: String -> IO () grab x = openItem x >>= putStr parse :: String -> IO () parse x = openItem x >>= putStr . show2 . parseTags where show2 [] = "[]" show2 xs = "[" ++ concat (intersperseNotBroken "\n," $ map show xs) ++ "\n]\n" -- the standard intersperse has a strictness bug which sucks! intersperseNotBroken :: a -> [a] -> [a] intersperseNotBroken _ [] = [] intersperseNotBroken sep (x:xs) = x : is xs where is [] = [] is (y:ys) = sep : y : is ys {-
-} haskellHitCount :: IO () haskellHitCount = do tags <- fmap parseTags $ openItem "http://haskell.org/haskellwiki/Haskell" let count = fromFooter $ head $ sections (~== "