dirty-haskell.org: dirty-haskell.org´s rss feeds

It's not crazy — it's having fun with types.

I extended the software suite inherited from math.kleen.org to include support for rss feeds. The heart of the issue is a ~80 line haskell script I chose to call, in a bout of creativity, “generate-rss.hs”. The script uses the feed package.

generate-rss.hs gets passed a title and a list of paths below ./lists to incorporate as items. It generates an empty feed structure, adds title and a (hardcoded) base url for RSS metadata, and iterates over the given paths — generating for each path an item to be included in the finished feed. This procedure makes use of a state monad (StateT (Feed, Maybe ClockTime) IO ()) to sequentially add items to the feed and keep track of the modification/change time of the newest path examined. Each item carries a title, an url, a date, and contents as follows:

Along the way two helper functions were introduced — if an implementation of those already exists in Prelude or somewhere else common please mail in a comment:

(<->) :: [(a -> b)] -> a -> [b]
[] <-> _ = []
(f:fs) <-> x = (f x:fs <-> x)

(<-->) :: [(a -> a)] -> a -> a
[] <--> x = x
(f:fs) <--> x = fs <--> (f x)


import Control.Applicative ((<*>), pure)

(<->) fs = (<*>) fs . pure

(<-->) = flip $ foldl (.) id

Thanks, viktor.