Here is a program that will parse and print XML feed URLs. I want to reuse most of it to add post date to each link. This adds a new concern of CLI and output formatting on top of parsing and (poor) error handling. I wonder how much of this code has enough value to put is in a wrapper utility and how much should be simply scrapped and basically left to user.
I also wonder whether
Text.Feed has enough value to use it (it's just XML represented by datatype) and I'm just traversing it.
module Main (main, extract) where import Text.Feed.Import import Text.Feed.Query (getItemLink, getFeedItems) import Data.Maybe import Control.Monad validate x = case x of Nothing -> error Just v -> const v extract selector feedString = selector $ (flip validate) "feed parsing failed" . parseFeedString $ feedString main :: IO () main = do feedString <- getContents mapM_ putStrLn $ extract selector feedString where selector = getFeedItems >=> (maybeToList . getItemLink)