rss-conduit-0.5.0.0: Streaming parser/renderer for the RSS standard.

Safe HaskellNone
LanguageHaskell2010

Text.RSS.Extensions

Contents

Description

Support for RSS extensions. Cf specification at http://web.resource.org/rss/1.0/modules/.

To implement an RSS extension:

  • Create a data-type, that will be used as a tag to identify the extension. To allow stacking multiple extensions, your data-type should have kind * -> *
data MyExtension otherExtensions = MyExtension otherExtensions
  • Implement extension types for <channel> and <item> elements:
data instance RssChannelExtension (MyExtension e) = MyExtensionChannel
  { -- ... add your fields ...
  , otherChannelExtensions :: RssChannelExtension e
  }

data instance RssItemExtension (MyExtension e) = MyExtensionItem
  { -- ... add your fields ...
  , otherItemExtensions :: RssItemExtension e
  }
-- Parser should rely on ZipConduit to be order-insensitive
instance ParseRssExtension e => ParseRssExtension (MyExtension e) where
  parseRssChannelExtension = getZipConduit $ MyExtensionChannel
    <$> ZipConduit -- ... parse fields
    <*> ZipConduit parseRssChannelExtension
  parseRssItemExtension = -- ... similarly

instance RenderRssExtension e => RenderRssExtension (MyExtension e) where
  renderRssChannelExtension (MyExtensionChannel {- fields -} otherChannelExtensions) = do
    -- ... render fields
    renderRssChannelExtension otherChannelExtensions
  renderRssItemExtension (MyExtensionItem {- fields -} otherItemExtensions) = -- ... similarly
Synopsis

Parsing

class ParseRssExtension a where Source #

Class of RSS extensions that can be parsed.

Methods

parseRssChannelExtension :: MonadThrow m => ConduitT Event o m (RssChannelExtension a) Source #

This parser will be fed with all Events within the <channel> element. Therefore, it is expected to ignore Events unrelated to the RSS extension.

parseRssItemExtension :: MonadThrow m => ConduitT Event o m (RssItemExtension a) Source #

This parser will be fed with all Events within the <item> element. Therefore, it is expected to ignore Events unrelated to the RSS extension.

Instances
ParseRssExtension NoExtensions Source # 
Instance details

Defined in Text.RSS.Extensions

ParseRssExtension a => ParseRssExtension (SyndicationModule a) Source # 
Instance details

Defined in Text.RSS.Extensions.Syndication

ParseRssExtension a => ParseRssExtension (DublinCoreModule a) Source # 
Instance details

Defined in Text.RSS.Extensions.DublinCore

ParseRssExtension a => ParseRssExtension (ContentModule a) Source # 
Instance details

Defined in Text.RSS.Extensions.Content

ParseRssExtension a => ParseRssExtension (AtomModule a) Source # 
Instance details

Defined in Text.RSS.Extensions.Atom

Rendering

class RenderRssExtension e where Source #

Class of RSS extensions that can be rendered.

Methods

renderRssChannelExtension :: Monad m => RssChannelExtension e -> ConduitT () Event m () Source #

Render extension for the <channel> element.

renderRssItemExtension :: Monad m => RssItemExtension e -> ConduitT () Event m () Source #

Render extension for the <item> element.

Instances
RenderRssExtension NoExtensions Source # 
Instance details

Defined in Text.RSS.Extensions

RenderRssExtension a => RenderRssExtension (SyndicationModule a) Source # 
Instance details

Defined in Text.RSS.Extensions.Syndication

RenderRssExtension a => RenderRssExtension (DublinCoreModule a) Source # 
Instance details

Defined in Text.RSS.Extensions.DublinCore

RenderRssExtension a => RenderRssExtension (ContentModule a) Source # 
Instance details

Defined in Text.RSS.Extensions.Content

RenderRssExtension a => RenderRssExtension (AtomModule a) Source # 
Instance details

Defined in Text.RSS.Extensions.Atom