Safe Haskell | None |
---|---|
Language | Haskell2010 |
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 }
- Implement
ParseRssExtension
andRenderRssExtension
type classes:
-- 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
- class ParseRssExtension a where
- parseRssChannelExtension :: MonadThrow m => ConduitT Event o m (RssChannelExtension a)
- parseRssItemExtension :: MonadThrow m => ConduitT Event o m (RssItemExtension a)
- class RenderRssExtension e where
- renderRssChannelExtension :: Monad m => RssChannelExtension e -> ConduitT () Event m ()
- renderRssItemExtension :: Monad m => RssItemExtension e -> ConduitT () Event m ()
Parsing
class ParseRssExtension a where Source #
Class of RSS extensions that can be parsed.
parseRssChannelExtension :: MonadThrow m => ConduitT Event o m (RssChannelExtension a) Source #
This parser will be fed with all Event
s within the <channel>
element.
Therefore, it is expected to ignore Event
s unrelated to the RSS extension.
parseRssItemExtension :: MonadThrow m => ConduitT Event o m (RssItemExtension a) Source #
Instances
Rendering
class RenderRssExtension e where Source #
Class of RSS extensions that can be rendered.
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.