category feedWorking with feedsSpecialised needseditdelete

This category is a work in progress






Libraries for generating and working with Atom/RSS feeds (Atom is a newer format, but RSS has wider adoption – most feed readers support both).

edit description
or press Ctrl+Enter to savemarkdown supported
#
feed (Hackage)
other
move item up move item down edit item info delete item
Summary edit summary

A big and fairly complete (but messy) library for generating, parsing, and validating Atom/RSS feeds.

Summary quit editing summary
Prosedit prosquit editing pros
  • The only library here that can parse feeds in addition to generating them.
    move trait up move trait down edit trait delete trait
  • Supports the most number of formats (Atom, RSS 2.x, and even old RSS 1.0).
    move trait up move trait down edit trait delete trait

press Ctrl+Enter or Enter to addmarkdown supportededit off
Consedit consquit editing cons
  • Uses String instead of Text.
    move trait up move trait down edit trait delete trait
  • Kinda complicated (and you would have to take several looks at others' feeds and at the documentation for Atom/RSS formats, since the library itself doesn't have much documentation).
    move trait up move trait down edit trait delete trait

press Ctrl+Enter or Enter to addmarkdown supportededit off
Ecosystemedit ecosystem
Ecosystemquit editing ecosystemor press Ctrl+Enter to savemarkdown supported
Notes
collapse notesedit notes

Links

Imports

For Atom feeds:

import qualified Text.Feed.Types as Feed
import qualified Text.Feed.Util  as Feed

import qualified Text.Atom.Feed        as Atom
import qualified Text.Atom.Feed.Export as Atom

-- from the “xml” package
import qualified Text.XML.Light.Output as XML

Creating an Atom feed

There are several types that you would need:

Each of these (apart from EntryContent and TextContent) is a record with lots of fields. You would almost never need all of those fields, so there are some helper functions available that make initialising them easier. For instance, to create a Link, use nullLink:

-- URI = String
nullLink :: URI -> Link

And then you can customise some of the fields:

nullLink "http://foo.bar" {
  linkTitle = Just "Foo Bar" }

Same with nullEntry and nullFeed; a complete example can be found here. Note that:

  • The example uses Strings as dates. If you want to convert UTCTime to the string format expected by the library, use toFeedDateStringUTC AtomKind (from Text.Feed.Util and Text.Feed.Types respectively).

  • The newest entry should be the 1st in the list.

  • The feed ID (i.e. the 1st parameter to nullFeed) doesn't have to be a link – for instance, for Github feeds it's something like

    tag:github.com,2008:/bergmark/feed/commits/master

    Entry IDs, contrary to what the example says, don't have to be links either.

collapse notesedit notes
#
rss (Hackage)
other
move item up move item down edit item info delete item
Summary edit summary

write something here!

Summary quit editing summary
Prosedit prosquit editing pros

    press Ctrl+Enter or Enter to addmarkdown supportededit off
    Consedit consquit editing cons
    • Can't generate Atom feeds.
      move trait up move trait down edit trait delete trait
    • Uses String instead of Text.
      move trait up move trait down edit trait delete trait

    press Ctrl+Enter or Enter to addmarkdown supportededit off
    Ecosystemedit ecosystem
    Ecosystemquit editing ecosystemor press Ctrl+Enter to savemarkdown supported
    Notes
    collapse notesedit notes

    <notes are empty>

    add something!

    #
    atom-basic (Hackage)
    other
    move item up move item down edit item info delete item
    Summary edit summary

    write something here!

    Summary quit editing summary
    Prosedit prosquit editing pros

      press Ctrl+Enter or Enter to addmarkdown supportededit off
      Consedit consquit editing cons

        press Ctrl+Enter or Enter to addmarkdown supportededit off
        Ecosystemedit ecosystem
        Ecosystemquit editing ecosystemor press Ctrl+Enter to savemarkdown supported
        Notes
        collapse notesedit notes

        <notes are empty>

        add something!

        #
        yesod-newsfeed (Hackage)
        other
        move item up move item down edit item info delete item
        Summary edit summary

        write something here!

        Summary quit editing summary
        Prosedit prosquit editing pros

          press Ctrl+Enter or Enter to addmarkdown supportededit off
          Consedit consquit editing cons
          • Not a standalone library – can only be used with Yesod.
            move trait up move trait down edit trait delete trait

          press Ctrl+Enter or Enter to addmarkdown supportededit off
          Ecosystemedit ecosystem
          Ecosystemquit editing ecosystemor press Ctrl+Enter to savemarkdown supported
          Notes
          collapse notesedit notes

          <notes are empty>

          add something!