{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
module Text.RSS.Extensions.Atom where
import Text.RSS.Extensions
import Text.RSS.Types
import Conduit (ZipConduit (..), headC, (.|))
import GHC.Generics
import Text.Atom.Conduit.Parse
import Text.Atom.Conduit.Render
import Text.Atom.Types
import Text.XML.Stream.Parse
newtype AtomModule a = AtomModule a
instance ParseRssExtension a => ParseRssExtension (AtomModule a) where
parseRssChannelExtension :: ConduitT Event o m (RssChannelExtension (AtomModule a))
parseRssChannelExtension = ZipConduit Event o m (RssChannelExtension (AtomModule a))
-> ConduitT Event o m (RssChannelExtension (AtomModule a))
forall i o (m :: * -> *) r. ZipConduit i o m r -> ConduitT i o m r
getZipConduit (ZipConduit Event o m (RssChannelExtension (AtomModule a))
-> ConduitT Event o m (RssChannelExtension (AtomModule a)))
-> ZipConduit Event o m (RssChannelExtension (AtomModule a))
-> ConduitT Event o m (RssChannelExtension (AtomModule a))
forall a b. (a -> b) -> a -> b
$ Maybe AtomLink
-> RssChannelExtension a -> RssChannelExtension (AtomModule a)
forall a.
Maybe AtomLink
-> RssChannelExtension a -> RssChannelExtension (AtomModule a)
AtomChannel
(Maybe AtomLink
-> RssChannelExtension a -> RssChannelExtension (AtomModule a))
-> ZipConduit Event o m (Maybe AtomLink)
-> ZipConduit
Event
o
m
(RssChannelExtension a -> RssChannelExtension (AtomModule a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m (Maybe AtomLink)
-> ZipConduit Event o m (Maybe AtomLink)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (ConduitT Event AtomLink m (Maybe AtomLink)
-> ConduitT Event AtomLink m ()
forall (m :: * -> *) b.
MonadThrow m =>
ConduitT Event b m (Maybe b) -> ConduitT Event b m ()
manyYield' ConduitT Event AtomLink m (Maybe AtomLink)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomLink)
atomLink ConduitT Event AtomLink m ()
-> ConduitM AtomLink o m (Maybe AtomLink)
-> ConduitT Event o m (Maybe AtomLink)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomLink o m (Maybe AtomLink)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
ZipConduit
Event
o
m
(RssChannelExtension a -> RssChannelExtension (AtomModule a))
-> ZipConduit Event o m (RssChannelExtension a)
-> ZipConduit Event o m (RssChannelExtension (AtomModule a))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT Event o m (RssChannelExtension a)
-> ZipConduit Event o m (RssChannelExtension a)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit ConduitT Event o m (RssChannelExtension a)
forall a (m :: * -> *) o.
(ParseRssExtension a, MonadThrow m) =>
ConduitT Event o m (RssChannelExtension a)
parseRssChannelExtension
parseRssItemExtension :: ConduitT Event o m (RssItemExtension (AtomModule a))
parseRssItemExtension = ZipConduit Event o m (RssItemExtension (AtomModule a))
-> ConduitT Event o m (RssItemExtension (AtomModule a))
forall i o (m :: * -> *) r. ZipConduit i o m r -> ConduitT i o m r
getZipConduit (ZipConduit Event o m (RssItemExtension (AtomModule a))
-> ConduitT Event o m (RssItemExtension (AtomModule a)))
-> ZipConduit Event o m (RssItemExtension (AtomModule a))
-> ConduitT Event o m (RssItemExtension (AtomModule a))
forall a b. (a -> b) -> a -> b
$ Maybe AtomLink
-> RssItemExtension a -> RssItemExtension (AtomModule a)
forall a.
Maybe AtomLink
-> RssItemExtension a -> RssItemExtension (AtomModule a)
AtomItem
(Maybe AtomLink
-> RssItemExtension a -> RssItemExtension (AtomModule a))
-> ZipConduit Event o m (Maybe AtomLink)
-> ZipConduit
Event o m (RssItemExtension a -> RssItemExtension (AtomModule a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m (Maybe AtomLink)
-> ZipConduit Event o m (Maybe AtomLink)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (ConduitT Event AtomLink m (Maybe AtomLink)
-> ConduitT Event AtomLink m ()
forall (m :: * -> *) b.
MonadThrow m =>
ConduitT Event b m (Maybe b) -> ConduitT Event b m ()
manyYield' ConduitT Event AtomLink m (Maybe AtomLink)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomLink)
atomLink ConduitT Event AtomLink m ()
-> ConduitM AtomLink o m (Maybe AtomLink)
-> ConduitT Event o m (Maybe AtomLink)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomLink o m (Maybe AtomLink)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
ZipConduit
Event o m (RssItemExtension a -> RssItemExtension (AtomModule a))
-> ZipConduit Event o m (RssItemExtension a)
-> ZipConduit Event o m (RssItemExtension (AtomModule a))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT Event o m (RssItemExtension a)
-> ZipConduit Event o m (RssItemExtension a)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit ConduitT Event o m (RssItemExtension a)
forall a (m :: * -> *) o.
(ParseRssExtension a, MonadThrow m) =>
ConduitT Event o m (RssItemExtension a)
parseRssItemExtension
instance RenderRssExtension a => RenderRssExtension (AtomModule a) where
renderRssChannelExtension :: RssChannelExtension (AtomModule a) -> ConduitT () Event m ()
renderRssChannelExtension AtomChannel{..} = do
(AtomLink -> ConduitT () Event m ())
-> Maybe AtomLink -> ConduitT () Event m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ AtomLink -> ConduitT () Event m ()
forall (m :: * -> *). Monad m => AtomLink -> ConduitT () Event m ()
renderAtomLink Maybe AtomLink
channelAtomLink
RssChannelExtension a -> ConduitT () Event m ()
forall e (m :: * -> *).
(RenderRssExtension e, Monad m) =>
RssChannelExtension e -> ConduitT () Event m ()
renderRssChannelExtension RssChannelExtension a
channelAtomOther
renderRssItemExtension :: RssItemExtension (AtomModule a) -> ConduitT () Event m ()
renderRssItemExtension AtomItem{..} = do
(AtomLink -> ConduitT () Event m ())
-> Maybe AtomLink -> ConduitT () Event m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ AtomLink -> ConduitT () Event m ()
forall (m :: * -> *). Monad m => AtomLink -> ConduitT () Event m ()
renderAtomLink Maybe AtomLink
itemAtomLink
RssItemExtension a -> ConduitT () Event m ()
forall e (m :: * -> *).
(RenderRssExtension e, Monad m) =>
RssItemExtension e -> ConduitT () Event m ()
renderRssItemExtension RssItemExtension a
itemAtomOther
data instance (AtomModule a) = AtomChannel
{ RssChannelExtension (AtomModule a) -> Maybe AtomLink
channelAtomLink :: Maybe AtomLink
, RssChannelExtension (AtomModule a) -> RssChannelExtension a
channelAtomOther :: RssChannelExtension a
}
deriving instance Eq (RssChannelExtension a) => Eq (RssChannelExtension (AtomModule a))
deriving instance Ord (RssChannelExtension a) => Ord (RssChannelExtension (AtomModule a))
deriving instance Show (RssChannelExtension a) => Show (RssChannelExtension (AtomModule a))
deriving instance Generic (RssChannelExtension a) => Generic (RssChannelExtension (AtomModule a))
data instance (AtomModule a) = AtomItem
{ RssItemExtension (AtomModule a) -> Maybe AtomLink
itemAtomLink :: Maybe AtomLink
, RssItemExtension (AtomModule a) -> RssItemExtension a
itemAtomOther :: RssItemExtension a
}
deriving instance Eq (RssItemExtension a) => Eq (RssItemExtension (AtomModule a))
deriving instance Ord (RssItemExtension a) => Ord (RssItemExtension (AtomModule a))
deriving instance Show (RssItemExtension a) => Show (RssItemExtension (AtomModule a))
deriving instance Generic (RssItemExtension a) => Generic (RssItemExtension (AtomModule a))