{-# LANGUAGE DataKinds          #-}
{-# LANGUAGE FlexibleContexts   #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE RankNTypes         #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell    #-}
{-# LANGUAGE TypeOperators      #-}
-- | Streaming parsers for the RSS 2.0 standard.
module Text.RSS.Conduit.Parse
  ( -- * Top-level
    rssDocument
    -- * Elements
  , rssCategory
  , rssCloud
  , rssEnclosure
  , rssGuid
  , rssImage
  , rssItem
  , rssSkipDays
  , rssSkipHours
  , rssSource
  , rssTextInput
  ) where

-- {{{ Imports
import           Text.RSS.Extensions
import           Text.RSS.Types

import           Conduit                      hiding (throwM)
import           Control.Applicative          hiding (many)
import           Control.Exception.Safe       as Exception
import           Control.Monad                (void)
import           Control.Monad.Fix
import           Data.Conduit
import           Data.List.NonEmpty           (NonEmpty (..), nonEmpty)
import           Data.Maybe
import           Data.Monoid
import           Data.Set                     (Set, fromList)
import           Data.Text                    as Text
import           Data.Text.Encoding
import           Data.Time.Clock
import           Data.Time.Format
import           Data.Time.LocalTime
import           Data.Time.RFC3339
import           Data.Time.RFC822
import           Data.Version
import           Data.XML.Types
import           Lens.Micro
import           Lens.Micro.TH
import           Safe
import           Text.ParserCombinators.ReadP (readP_to_S)
import           Text.Read                    (readMaybe)
import           Text.XML.Stream.Parse
import           URI.ByteString
-- }}}

-- {{{ Util
asRssURI :: MonadThrow m => Text -> m RssURI
asRssURI :: Text -> m RssURI
asRssURI Text
t = case (Text -> Either URIParseError (URIRef Absolute)
parseURI' Text
t, Text -> Either URIParseError (URIRef Relative)
parseRelativeRef' Text
t) of
  (Right URIRef Absolute
u, Either URIParseError (URIRef Relative)
_) -> RssURI -> m RssURI
forall (m :: * -> *) a. Monad m => a -> m a
return (RssURI -> m RssURI) -> RssURI -> m RssURI
forall a b. (a -> b) -> a -> b
$ URIRef Absolute -> RssURI
forall a. URIRef a -> RssURI
RssURI URIRef Absolute
u
  (Either URIParseError (URIRef Absolute)
_, Right URIRef Relative
u) -> RssURI -> m RssURI
forall (m :: * -> *) a. Monad m => a -> m a
return (RssURI -> m RssURI) -> RssURI -> m RssURI
forall a b. (a -> b) -> a -> b
$ URIRef Relative -> RssURI
forall a. URIRef a -> RssURI
RssURI URIRef Relative
u
  (Either URIParseError (URIRef Absolute)
_, Left URIParseError
e)  -> RssException -> m RssURI
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (RssException -> m RssURI) -> RssException -> m RssURI
forall a b. (a -> b) -> a -> b
$ URIParseError -> RssException
InvalidURI URIParseError
e
  where parseURI' :: Text -> Either URIParseError (URIRef Absolute)
parseURI' = URIParserOptions
-> ByteString -> Either URIParseError (URIRef Absolute)
parseURI URIParserOptions
laxURIParserOptions (ByteString -> Either URIParseError (URIRef Absolute))
-> (Text -> ByteString)
-> Text
-> Either URIParseError (URIRef Absolute)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ByteString
encodeUtf8
        parseRelativeRef' :: Text -> Either URIParseError (URIRef Relative)
parseRelativeRef' = URIParserOptions
-> ByteString -> Either URIParseError (URIRef Relative)
parseRelativeRef URIParserOptions
laxURIParserOptions (ByteString -> Either URIParseError (URIRef Relative))
-> (Text -> ByteString)
-> Text
-> Either URIParseError (URIRef Relative)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ByteString
encodeUtf8

nullURI :: RssURI
nullURI :: RssURI
nullURI = URIRef Relative -> RssURI
forall a. URIRef a -> RssURI
RssURI (URIRef Relative -> RssURI) -> URIRef Relative -> RssURI
forall a b. (a -> b) -> a -> b
$ Maybe Authority
-> ByteString -> Query -> Maybe ByteString -> URIRef Relative
RelativeRef Maybe Authority
forall a. Maybe a
Nothing ByteString
"" ([(ByteString, ByteString)] -> Query
Query []) Maybe ByteString
forall a. Maybe a
Nothing

asInt :: MonadThrow m => Text -> m Int
asInt :: Text -> m Int
asInt Text
t = m Int -> (Int -> m Int) -> Maybe Int -> m Int
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (RssException -> m Int
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (RssException -> m Int) -> RssException -> m Int
forall a b. (a -> b) -> a -> b
$ Text -> RssException
InvalidInt Text
t) Int -> m Int
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Int -> m Int) -> (String -> Maybe Int) -> String -> m Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Int
forall a. Read a => String -> Maybe a
readMaybe (String -> m Int) -> String -> m Int
forall a b. (a -> b) -> a -> b
$ Text -> String
unpack Text
t

asBool :: MonadThrow m => Text -> m Bool
asBool :: Text -> m Bool
asBool Text
"true"  = Bool -> m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
asBool Text
"false" = Bool -> m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
asBool Text
t       = RssException -> m Bool
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (RssException -> m Bool) -> RssException -> m Bool
forall a b. (a -> b) -> a -> b
$ Text -> RssException
InvalidBool Text
t

asVersion :: MonadThrow m => Text -> m Version
asVersion :: Text -> m Version
asVersion Text
t = m Version
-> ((Version, String) -> m Version)
-> Maybe (Version, String)
-> m Version
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (RssException -> m Version
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (RssException -> m Version) -> RssException -> m Version
forall a b. (a -> b) -> a -> b
$ Text -> RssException
InvalidVersion Text
t) (Version -> m Version
forall (m :: * -> *) a. Monad m => a -> m a
return (Version -> m Version)
-> ((Version, String) -> Version) -> (Version, String) -> m Version
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Version, String) -> Version
forall a b. (a, b) -> a
fst) (Maybe (Version, String) -> m Version)
-> (String -> Maybe (Version, String)) -> String -> m Version
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Version, String)] -> Maybe (Version, String)
forall a. [a] -> Maybe a
headMay ([(Version, String)] -> Maybe (Version, String))
-> (String -> [(Version, String)])
-> String
-> Maybe (Version, String)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReadP Version -> String -> [(Version, String)]
forall a. ReadP a -> ReadS a
readP_to_S ReadP Version
parseVersion (String -> m Version) -> String -> m Version
forall a b. (a -> b) -> a -> b
$ Text -> String
unpack Text
t

asCloudProtocol :: MonadThrow m => Text -> m CloudProtocol
asCloudProtocol :: Text -> m CloudProtocol
asCloudProtocol Text
"xml-rpc"   = CloudProtocol -> m CloudProtocol
forall (m :: * -> *) a. Monad m => a -> m a
return CloudProtocol
ProtocolXmlRpc
asCloudProtocol Text
"soap"      = CloudProtocol -> m CloudProtocol
forall (m :: * -> *) a. Monad m => a -> m a
return CloudProtocol
ProtocolSoap
asCloudProtocol Text
"http-post" = CloudProtocol -> m CloudProtocol
forall (m :: * -> *) a. Monad m => a -> m a
return CloudProtocol
ProtocolHttpPost
asCloudProtocol Text
t           = RssException -> m CloudProtocol
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (RssException -> m CloudProtocol)
-> RssException -> m CloudProtocol
forall a b. (a -> b) -> a -> b
$ Text -> RssException
InvalidProtocol Text
t

-- | Like 'tagName' but ignores the namespace.
tagName' :: MonadThrow m => Text -> AttrParser a -> (a -> ConduitM Event o m b) -> ConduitM Event o m (Maybe b)
tagName' :: Text
-> AttrParser a
-> (a -> ConduitM Event o m b)
-> ConduitM Event o m (Maybe b)
tagName' Text
t = NameMatcher Name
-> AttrParser a
-> (a -> ConduitM Event o m b)
-> ConduitM Event o m (Maybe b)
forall (m :: * -> *) a b o c.
MonadThrow m =>
NameMatcher a
-> AttrParser b
-> (b -> ConduitT Event o m c)
-> ConduitT Event o m (Maybe c)
tag' ((Name -> Bool) -> NameMatcher Name
matching ((Name -> Bool) -> NameMatcher Name)
-> (Name -> Bool) -> NameMatcher Name
forall a b. (a -> b) -> a -> b
$ \Name
n -> Name -> Text
nameLocalName Name
n Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
t Bool -> Bool -> Bool
&& Maybe Text -> Bool
forall a. Maybe a -> Bool
isNothing (Name -> Maybe Text
nameNamespace Name
n))

-- | Tag which content is a date-time.
-- RSS specification demands that date-times are formatted according to RFC 822,
-- but this implementation is more lenient.
tagDate :: (MonadThrow m) => NameMatcher a -> ConduitM Event o m (Maybe UTCTime)
tagDate :: NameMatcher a -> ConduitM Event o m (Maybe UTCTime)
tagDate NameMatcher a
name = NameMatcher a
-> ConduitT Event o m UTCTime -> ConduitM Event o m (Maybe UTCTime)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher a
name (ConduitT Event o m UTCTime -> ConduitM Event o m (Maybe UTCTime))
-> ConduitT Event o m UTCTime -> ConduitM Event o m (Maybe UTCTime)
forall a b. (a -> b) -> a -> b
$ do
  Text
text <- ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
  ConduitT Event o m UTCTime
-> (UTCTime -> ConduitT Event o m UTCTime)
-> Maybe UTCTime
-> ConduitT Event o m UTCTime
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (RssException -> ConduitT Event o m UTCTime
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throw (RssException -> ConduitT Event o m UTCTime)
-> RssException -> ConduitT Event o m UTCTime
forall a b. (a -> b) -> a -> b
$ Text -> RssException
InvalidTime Text
text) UTCTime -> ConduitT Event o m UTCTime
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe UTCTime -> ConduitT Event o m UTCTime)
-> Maybe UTCTime -> ConduitT Event o m UTCTime
forall a b. (a -> b) -> a -> b
$
    Text -> Maybe UTCTime
forall t. TextualMonoid t => t -> Maybe UTCTime
rfc822Time Text
text Maybe UTCTime -> Maybe UTCTime -> Maybe UTCTime
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Text -> Maybe UTCTime
forall t. TextualMonoid t => t -> Maybe UTCTime
rfc3339Time Text
text Maybe UTCTime -> Maybe UTCTime -> Maybe UTCTime
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Text -> Maybe UTCTime
forall t. TextualMonoid t => t -> Maybe UTCTime
rfc3339Date Text
text Maybe UTCTime -> Maybe UTCTime -> Maybe UTCTime
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Text -> Maybe UTCTime
forall (m :: * -> *) t. (MonadFail m, ParseTime t) => Text -> m t
customDate1 Text
text Maybe UTCTime -> Maybe UTCTime -> Maybe UTCTime
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Text -> Maybe UTCTime
forall (m :: * -> *) t. (MonadFail m, ParseTime t) => Text -> m t
customDate2 Text
text
  where rfc822Time :: t -> Maybe UTCTime
rfc822Time t
t = ZonedTime -> UTCTime
zonedTimeToUTC (ZonedTime -> UTCTime) -> Maybe ZonedTime -> Maybe UTCTime
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> t -> Maybe ZonedTime
forall t. TextualMonoid t => t -> Maybe ZonedTime
parseTimeRFC822 t
t
        rfc3339Time :: t -> Maybe UTCTime
rfc3339Time t
t = ZonedTime -> UTCTime
zonedTimeToUTC (ZonedTime -> UTCTime) -> Maybe ZonedTime -> Maybe UTCTime
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> t -> Maybe ZonedTime
forall t. TextualMonoid t => t -> Maybe ZonedTime
parseTimeRFC3339 t
t
        rfc3339Date :: t -> Maybe UTCTime
rfc3339Date t
t = Day -> DiffTime -> UTCTime
UTCTime (Day -> DiffTime -> UTCTime)
-> Maybe Day -> Maybe (DiffTime -> UTCTime)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> t -> Maybe Day
forall t. TextualMonoid t => t -> Maybe Day
parseDateRFC3339 t
t Maybe (DiffTime -> UTCTime) -> Maybe DiffTime -> Maybe UTCTime
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> DiffTime -> Maybe DiffTime
forall (f :: * -> *) a. Applicative f => a -> f a
pure DiffTime
0
        customDate1 :: Text -> m t
customDate1 Text
t = Bool -> TimeLocale -> String -> String -> m t
forall (m :: * -> *) t.
(MonadFail m, ParseTime t) =>
Bool -> TimeLocale -> String -> String -> m t
parseTimeM Bool
True TimeLocale
defaultTimeLocale String
"%F %T" (Text -> String
Text.unpack Text
t)
        customDate2 :: Text -> m t
customDate2 Text
t = Bool -> TimeLocale -> String -> String -> m t
forall (m :: * -> *) t.
(MonadFail m, ParseTime t) =>
Bool -> TimeLocale -> String -> String -> m t
parseTimeM Bool
True TimeLocale
defaultTimeLocale String
"%F %R" (Text -> String
Text.unpack Text
t)


headRequiredC :: MonadThrow m => Text -> ConduitT a b m a
headRequiredC :: Text -> ConduitT a b m a
headRequiredC Text
e = ConduitT a b m a
-> (a -> ConduitT a b m a) -> Maybe a -> ConduitT a b m a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (RssException -> ConduitT a b m a
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throw (RssException -> ConduitT a b m a)
-> RssException -> ConduitT a b m a
forall a b. (a -> b) -> a -> b
$ Text -> RssException
MissingElement Text
e) a -> ConduitT a b m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe a -> ConduitT a b m a)
-> ConduitT a b m (Maybe a) -> ConduitT a b m a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ConduitT a b m (Maybe a)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC

projectC :: Monad m => Traversal' a b -> ConduitT a b m ()
projectC :: Traversal' a b -> ConduitT a b m ()
projectC Traversal' a b
prism = (ConduitT a b m () -> ConduitT a b m ()) -> ConduitT a b m ()
forall a. (a -> a) -> a
fix ((ConduitT a b m () -> ConduitT a b m ()) -> ConduitT a b m ())
-> (ConduitT a b m () -> ConduitT a b m ()) -> ConduitT a b m ()
forall a b. (a -> b) -> a -> b
$ \ConduitT a b m ()
recurse -> do
  Maybe a
item <- ConduitT a b m (Maybe a)
forall (m :: * -> *) i. Monad m => Consumer i m (Maybe i)
await
  case (Maybe a
item, Maybe a
item Maybe a -> Getting (First b) (Maybe a) b -> Maybe b
forall s a. s -> Getting (First a) s a -> Maybe a
^? ((a -> Const (First b) a) -> Maybe a -> Const (First b) (Maybe a)
forall a a'. Traversal (Maybe a) (Maybe a') a a'
_Just ((a -> Const (First b) a) -> Maybe a -> Const (First b) (Maybe a))
-> ((b -> Const (First b) b) -> a -> Const (First b) a)
-> Getting (First b) (Maybe a) b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b -> Const (First b) b) -> a -> Const (First b) a
Traversal' a b
prism)) of
    (Maybe a
_, Just b
a) -> b -> ConduitT a b m ()
forall (m :: * -> *) o i. Monad m => o -> ConduitT i o m ()
yield b
a ConduitT a b m () -> ConduitT a b m () -> ConduitT a b m ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ConduitT a b m ()
recurse
    (Just a
_, Maybe b
_) -> ConduitT a b m ()
recurse
    (Maybe a, Maybe b)
_           -> () -> ConduitT a b m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
-- }}}


-- | Parse a @\<skipHours\>@ element.
rssSkipHours :: MonadThrow m => ConduitM Event o m (Maybe (Set Hour))
rssSkipHours :: ConduitM Event o m (Maybe (Set Hour))
rssSkipHours = NameMatcher Name
-> ConduitT Event o m (Set Hour)
-> ConduitM Event o m (Maybe (Set Hour))
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"skipHours" (ConduitT Event o m (Set Hour)
 -> ConduitM Event o m (Maybe (Set Hour)))
-> ConduitT Event o m (Set Hour)
-> ConduitM Event o m (Maybe (Set Hour))
forall a b. (a -> b) -> a -> b
$
  [Hour] -> Set Hour
forall a. Ord a => [a] -> Set a
fromList ([Hour] -> Set Hour)
-> ConduitT Event o m [Hour] -> ConduitT Event o m (Set Hour)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ConduitT Event Hour m (Maybe Hour) -> ConduitT Event Hour m ()
forall (m :: * -> *) b.
MonadThrow m =>
ConduitT Event b m (Maybe b) -> ConduitT Event b m ()
manyYield' (NameMatcher Name
-> ConduitT Event Hour m Hour -> ConduitT Event Hour m (Maybe Hour)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"hour" (ConduitT Event Hour m Hour -> ConduitT Event Hour m (Maybe Hour))
-> ConduitT Event Hour m Hour -> ConduitT Event Hour m (Maybe Hour)
forall a b. (a -> b) -> a -> b
$ ConduitT Event Hour m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event Hour m Text
-> (Text -> ConduitT Event Hour m Int) -> ConduitT Event Hour m Int
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitT Event Hour m Int
forall (m :: * -> *). MonadThrow m => Text -> m Int
asInt ConduitT Event Hour m Int
-> (Int -> ConduitT Event Hour m Hour)
-> ConduitT Event Hour m Hour
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Int -> ConduitT Event Hour m Hour
forall (m :: * -> *). MonadThrow m => Int -> m Hour
asHour) ConduitT Event Hour m ()
-> ConduitM Hour o m [Hour] -> ConduitT Event o m [Hour]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM Hour o m [Hour]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)

-- | Parse a @\<skipDays\>@ element.
rssSkipDays :: MonadThrow m => ConduitM Event o m (Maybe (Set Day))
rssSkipDays :: ConduitM Event o m (Maybe (Set Day))
rssSkipDays = NameMatcher Name
-> ConduitT Event o m (Set Day)
-> ConduitM Event o m (Maybe (Set Day))
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"skipDays" (ConduitT Event o m (Set Day)
 -> ConduitM Event o m (Maybe (Set Day)))
-> ConduitT Event o m (Set Day)
-> ConduitM Event o m (Maybe (Set Day))
forall a b. (a -> b) -> a -> b
$
  [Day] -> Set Day
forall a. Ord a => [a] -> Set a
fromList ([Day] -> Set Day)
-> ConduitT Event o m [Day] -> ConduitT Event o m (Set Day)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ConduitT Event Day m (Maybe Day) -> ConduitT Event Day m ()
forall (m :: * -> *) b.
MonadThrow m =>
ConduitT Event b m (Maybe b) -> ConduitT Event b m ()
manyYield' (NameMatcher Name
-> ConduitT Event Day m Day -> ConduitT Event Day m (Maybe Day)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"day" (ConduitT Event Day m Day -> ConduitT Event Day m (Maybe Day))
-> ConduitT Event Day m Day -> ConduitT Event Day m (Maybe Day)
forall a b. (a -> b) -> a -> b
$ ConduitT Event Day m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event Day m Text
-> (Text -> ConduitT Event Day m Day) -> ConduitT Event Day m Day
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitT Event Day m Day
forall (m :: * -> *). MonadThrow m => Text -> m Day
asDay) ConduitT Event Day m ()
-> ConduitM Day o m [Day] -> ConduitT Event o m [Day]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM Day o m [Day]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)


data TextInputPiece = TextInputTitle { TextInputPiece -> Text
__textInputTitle :: Text }
                    | TextInputDescription { TextInputPiece -> Text
__textInputDescription :: Text }
                    | TextInputName { TextInputPiece -> Text
__textInputName :: Text }
                    | TextInputLink { TextInputPiece -> RssURI
__textInputLink :: RssURI }

makeLenses ''TextInputPiece

-- | Parse a @\<textInput\>@ element.
rssTextInput :: MonadThrow m => ConduitM Event o m (Maybe RssTextInput)
rssTextInput :: ConduitM Event o m (Maybe RssTextInput)
rssTextInput = NameMatcher Name
-> ConduitT Event o m RssTextInput
-> ConduitM Event o m (Maybe RssTextInput)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"textInput" (ConduitT Event o m RssTextInput
 -> ConduitM Event o m (Maybe RssTextInput))
-> ConduitT Event o m RssTextInput
-> ConduitM Event o m (Maybe RssTextInput)
forall a b. (a -> b) -> a -> b
$ (ConduitT Event TextInputPiece m (Maybe TextInputPiece)
-> ConduitT Event TextInputPiece m ()
forall (m :: * -> *) b.
MonadThrow m =>
ConduitT Event b m (Maybe b) -> ConduitT Event b m ()
manyYield' ([ConduitT Event TextInputPiece m (Maybe TextInputPiece)]
-> ConduitT Event TextInputPiece m (Maybe TextInputPiece)
forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose [ConduitT Event TextInputPiece m (Maybe TextInputPiece)]
forall o. [ConduitT Event o m (Maybe TextInputPiece)]
piece) ConduitT Event TextInputPiece m ()
-> ConduitM TextInputPiece o m RssTextInput
-> ConduitT Event o m RssTextInput
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM TextInputPiece o m RssTextInput
forall o. ConduitT TextInputPiece o m RssTextInput
parser) ConduitT Event o m RssTextInput
-> ConduitT Event o m [()] -> ConduitT Event o m RssTextInput
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ConduitT Event o m (Maybe ()) -> ConduitT Event o m [()]
forall (m :: * -> *) o a.
Monad m =>
ConduitT Event o m (Maybe a) -> ConduitT Event o m [a]
many ConduitT Event o m (Maybe ())
forall (m :: * -> *) o.
MonadThrow m =>
ConduitT Event o m (Maybe ())
ignoreAnyTreeContent where
  parser :: ConduitT TextInputPiece o m RssTextInput
parser = ZipConduit TextInputPiece o m RssTextInput
-> ConduitT TextInputPiece o m RssTextInput
forall i o (m :: * -> *) r. ZipConduit i o m r -> ConduitT i o m r
getZipConduit (ZipConduit TextInputPiece o m RssTextInput
 -> ConduitT TextInputPiece o m RssTextInput)
-> ZipConduit TextInputPiece o m RssTextInput
-> ConduitT TextInputPiece o m RssTextInput
forall a b. (a -> b) -> a -> b
$ Text -> Text -> Text -> RssURI -> RssTextInput
RssTextInput
    (Text -> Text -> Text -> RssURI -> RssTextInput)
-> ZipConduit TextInputPiece o m Text
-> ZipConduit
     TextInputPiece o m (Text -> Text -> RssURI -> RssTextInput)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT TextInputPiece o m Text
-> ZipConduit TextInputPiece o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' TextInputPiece Text -> ConduitT TextInputPiece Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' TextInputPiece Text
_textInputTitle ConduitT TextInputPiece Text m ()
-> ConduitM Text o m Text -> ConduitT TextInputPiece o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a b. MonadThrow m => Text -> ConduitT a b m a
headRequiredC Text
"Missing <title> element")
    ZipConduit
  TextInputPiece o m (Text -> Text -> RssURI -> RssTextInput)
-> ZipConduit TextInputPiece o m Text
-> ZipConduit TextInputPiece o m (Text -> RssURI -> RssTextInput)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT TextInputPiece o m Text
-> ZipConduit TextInputPiece o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' TextInputPiece Text -> ConduitT TextInputPiece Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' TextInputPiece Text
_textInputDescription ConduitT TextInputPiece Text m ()
-> ConduitM Text o m Text -> ConduitT TextInputPiece o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a b. MonadThrow m => Text -> ConduitT a b m a
headRequiredC Text
"Missing <description> element")
    ZipConduit TextInputPiece o m (Text -> RssURI -> RssTextInput)
-> ZipConduit TextInputPiece o m Text
-> ZipConduit TextInputPiece o m (RssURI -> RssTextInput)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT TextInputPiece o m Text
-> ZipConduit TextInputPiece o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' TextInputPiece Text -> ConduitT TextInputPiece Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' TextInputPiece Text
_textInputName ConduitT TextInputPiece Text m ()
-> ConduitM Text o m Text -> ConduitT TextInputPiece o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a b. MonadThrow m => Text -> ConduitT a b m a
headRequiredC Text
"Missing <name> element")
    ZipConduit TextInputPiece o m (RssURI -> RssTextInput)
-> ZipConduit TextInputPiece o m RssURI
-> ZipConduit TextInputPiece o m RssTextInput
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT TextInputPiece o m RssURI
-> ZipConduit TextInputPiece o m RssURI
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' TextInputPiece RssURI
-> ConduitT TextInputPiece RssURI m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' TextInputPiece RssURI
_textInputLink ConduitT TextInputPiece RssURI m ()
-> ConduitM RssURI o m RssURI -> ConduitT TextInputPiece o m RssURI
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM RssURI o m RssURI
forall (m :: * -> *) a b. MonadThrow m => Text -> ConduitT a b m a
headRequiredC Text
"Missing <link> element")
  piece :: [ConduitT Event o m (Maybe TextInputPiece)]
piece = [ (Text -> TextInputPiece) -> Maybe Text -> Maybe TextInputPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> TextInputPiece
TextInputTitle (Maybe Text -> Maybe TextInputPiece)
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe TextInputPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"title" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (Text -> TextInputPiece) -> Maybe Text -> Maybe TextInputPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> TextInputPiece
TextInputDescription (Maybe Text -> Maybe TextInputPiece)
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe TextInputPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"description" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (Text -> TextInputPiece) -> Maybe Text -> Maybe TextInputPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> TextInputPiece
TextInputName (Maybe Text -> Maybe TextInputPiece)
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe TextInputPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"name" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (RssURI -> TextInputPiece) -> Maybe RssURI -> Maybe TextInputPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssURI -> TextInputPiece
TextInputLink (Maybe RssURI -> Maybe TextInputPiece)
-> ConduitT Event o m (Maybe RssURI)
-> ConduitT Event o m (Maybe TextInputPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m RssURI -> ConduitT Event o m (Maybe RssURI)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"link" (ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event o m Text
-> (Text -> ConduitT Event o m RssURI) -> ConduitT Event o m RssURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitT Event o m RssURI
forall (m :: * -> *). MonadThrow m => Text -> m RssURI
asRssURI)
          ]



data ImagePiece = ImageUri { ImagePiece -> RssURI
__imageUri :: RssURI }
                | ImageTitle { ImagePiece -> Text
__imageTitle :: Text }
                | ImageLink { ImagePiece -> RssURI
__imageLink :: RssURI }
                | ImageWidth { ImagePiece -> Int
__imageWidth :: Int }
                | ImageHeight { ImagePiece -> Int
__imageHeight :: Int }
                | ImageDescription { ImagePiece -> Text
__imageDescription :: Text }

makeLenses ''ImagePiece

-- | Parse an @\<image\>@ element.
rssImage :: (MonadThrow m) => ConduitM Event o m (Maybe RssImage)
rssImage :: ConduitM Event o m (Maybe RssImage)
rssImage = NameMatcher Name
-> ConduitT Event o m RssImage
-> ConduitM Event o m (Maybe RssImage)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"image" (ConduitT Event o m RssImage
 -> ConduitM Event o m (Maybe RssImage))
-> ConduitT Event o m RssImage
-> ConduitM Event o m (Maybe RssImage)
forall a b. (a -> b) -> a -> b
$ (ConduitT Event ImagePiece m (Maybe ImagePiece)
-> ConduitT Event ImagePiece m ()
forall (m :: * -> *) b.
MonadThrow m =>
ConduitT Event b m (Maybe b) -> ConduitT Event b m ()
manyYield' ([ConduitT Event ImagePiece m (Maybe ImagePiece)]
-> ConduitT Event ImagePiece m (Maybe ImagePiece)
forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose [ConduitT Event ImagePiece m (Maybe ImagePiece)]
forall o. [ConduitT Event o m (Maybe ImagePiece)]
piece) ConduitT Event ImagePiece m ()
-> ConduitM ImagePiece o m RssImage -> ConduitT Event o m RssImage
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM ImagePiece o m RssImage
forall o. ConduitT ImagePiece o m RssImage
parser) ConduitT Event o m RssImage
-> ConduitT Event o m [()] -> ConduitT Event o m RssImage
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ConduitT Event o m (Maybe ()) -> ConduitT Event o m [()]
forall (m :: * -> *) o a.
Monad m =>
ConduitT Event o m (Maybe a) -> ConduitT Event o m [a]
many ConduitT Event o m (Maybe ())
forall (m :: * -> *) o.
MonadThrow m =>
ConduitT Event o m (Maybe ())
ignoreAnyTreeContent where
  parser :: ConduitT ImagePiece o m RssImage
parser = ZipConduit ImagePiece o m RssImage
-> ConduitT ImagePiece o m RssImage
forall i o (m :: * -> *) r. ZipConduit i o m r -> ConduitT i o m r
getZipConduit (ZipConduit ImagePiece o m RssImage
 -> ConduitT ImagePiece o m RssImage)
-> ZipConduit ImagePiece o m RssImage
-> ConduitT ImagePiece o m RssImage
forall a b. (a -> b) -> a -> b
$ RssURI
-> Text -> RssURI -> Maybe Int -> Maybe Int -> Text -> RssImage
RssImage
    (RssURI
 -> Text -> RssURI -> Maybe Int -> Maybe Int -> Text -> RssImage)
-> ZipConduit ImagePiece o m RssURI
-> ZipConduit
     ImagePiece
     o
     m
     (Text -> RssURI -> Maybe Int -> Maybe Int -> Text -> RssImage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT ImagePiece o m RssURI -> ZipConduit ImagePiece o m RssURI
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ImagePiece RssURI -> ConduitT ImagePiece RssURI m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ImagePiece RssURI
_imageUri ConduitT ImagePiece RssURI m ()
-> ConduitM RssURI o m RssURI -> ConduitT ImagePiece o m RssURI
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM RssURI o m RssURI
forall (m :: * -> *) a b. MonadThrow m => Text -> ConduitT a b m a
headRequiredC Text
"Missing <url> element")
    ZipConduit
  ImagePiece
  o
  m
  (Text -> RssURI -> Maybe Int -> Maybe Int -> Text -> RssImage)
-> ZipConduit ImagePiece o m Text
-> ZipConduit
     ImagePiece
     o
     m
     (RssURI -> Maybe Int -> Maybe Int -> Text -> RssImage)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT ImagePiece o m Text -> ZipConduit ImagePiece o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ImagePiece Text -> ConduitT ImagePiece Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ImagePiece Text
_imageTitle ConduitT ImagePiece Text m ()
-> ConduitM Text o m Text -> ConduitT ImagePiece o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a o. Monad m => a -> ConduitT a o m a
headDefC Text
"Unnamed image")  -- Lenient
    ZipConduit
  ImagePiece
  o
  m
  (RssURI -> Maybe Int -> Maybe Int -> Text -> RssImage)
-> ZipConduit ImagePiece o m RssURI
-> ZipConduit
     ImagePiece o m (Maybe Int -> Maybe Int -> Text -> RssImage)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT ImagePiece o m RssURI -> ZipConduit ImagePiece o m RssURI
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ImagePiece RssURI -> ConduitT ImagePiece RssURI m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ImagePiece RssURI
_imageLink ConduitT ImagePiece RssURI m ()
-> ConduitM RssURI o m RssURI -> ConduitT ImagePiece o m RssURI
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| RssURI -> ConduitM RssURI o m RssURI
forall (m :: * -> *) a o. Monad m => a -> ConduitT a o m a
headDefC RssURI
nullURI)  -- Lenient
    ZipConduit
  ImagePiece o m (Maybe Int -> Maybe Int -> Text -> RssImage)
-> ZipConduit ImagePiece o m (Maybe Int)
-> ZipConduit ImagePiece o m (Maybe Int -> Text -> RssImage)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT ImagePiece o m (Maybe Int)
-> ZipConduit ImagePiece o m (Maybe Int)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ImagePiece Int -> ConduitT ImagePiece Int m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ImagePiece Int
_imageWidth ConduitT ImagePiece Int m ()
-> ConduitM Int o m (Maybe Int)
-> ConduitT ImagePiece o m (Maybe Int)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM Int o m (Maybe Int)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit ImagePiece o m (Maybe Int -> Text -> RssImage)
-> ZipConduit ImagePiece o m (Maybe Int)
-> ZipConduit ImagePiece o m (Text -> RssImage)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT ImagePiece o m (Maybe Int)
-> ZipConduit ImagePiece o m (Maybe Int)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ImagePiece Int -> ConduitT ImagePiece Int m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ImagePiece Int
_imageHeight ConduitT ImagePiece Int m ()
-> ConduitM Int o m (Maybe Int)
-> ConduitT ImagePiece o m (Maybe Int)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM Int o m (Maybe Int)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit ImagePiece o m (Text -> RssImage)
-> ZipConduit ImagePiece o m Text
-> ZipConduit ImagePiece o m RssImage
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT ImagePiece o m Text -> ZipConduit ImagePiece o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ImagePiece Text -> ConduitT ImagePiece Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ImagePiece Text
_imageDescription ConduitT ImagePiece Text m ()
-> ConduitM Text o m Text -> ConduitT ImagePiece o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a o. Monad m => a -> ConduitT a o m a
headDefC Text
"")
  piece :: [ConduitT Event o m (Maybe ImagePiece)]
piece = [ (RssURI -> ImagePiece) -> Maybe RssURI -> Maybe ImagePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssURI -> ImagePiece
ImageUri (Maybe RssURI -> Maybe ImagePiece)
-> ConduitT Event o m (Maybe RssURI)
-> ConduitT Event o m (Maybe ImagePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m RssURI -> ConduitT Event o m (Maybe RssURI)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"url" (ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event o m Text
-> (Text -> ConduitT Event o m RssURI) -> ConduitT Event o m RssURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitT Event o m RssURI
forall (m :: * -> *). MonadThrow m => Text -> m RssURI
asRssURI)
          , (Text -> ImagePiece) -> Maybe Text -> Maybe ImagePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> ImagePiece
ImageTitle (Maybe Text -> Maybe ImagePiece)
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe ImagePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"title" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (RssURI -> ImagePiece) -> Maybe RssURI -> Maybe ImagePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssURI -> ImagePiece
ImageLink (Maybe RssURI -> Maybe ImagePiece)
-> ConduitT Event o m (Maybe RssURI)
-> ConduitT Event o m (Maybe ImagePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m RssURI -> ConduitT Event o m (Maybe RssURI)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"link" (ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event o m Text
-> (Text -> ConduitT Event o m RssURI) -> ConduitT Event o m RssURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitT Event o m RssURI
forall (m :: * -> *). MonadThrow m => Text -> m RssURI
asRssURI)
          , (Int -> ImagePiece) -> Maybe Int -> Maybe ImagePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> ImagePiece
ImageWidth (Maybe Int -> Maybe ImagePiece)
-> ConduitT Event o m (Maybe Int)
-> ConduitT Event o m (Maybe ImagePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Int -> ConduitT Event o m (Maybe Int)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"width" (ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event o m Text
-> (Text -> ConduitT Event o m Int) -> ConduitT Event o m Int
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitT Event o m Int
forall (m :: * -> *). MonadThrow m => Text -> m Int
asInt)
          , (Int -> ImagePiece) -> Maybe Int -> Maybe ImagePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> ImagePiece
ImageHeight (Maybe Int -> Maybe ImagePiece)
-> ConduitT Event o m (Maybe Int)
-> ConduitT Event o m (Maybe ImagePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Int -> ConduitT Event o m (Maybe Int)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"height" (ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event o m Text
-> (Text -> ConduitT Event o m Int) -> ConduitT Event o m Int
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitT Event o m Int
forall (m :: * -> *). MonadThrow m => Text -> m Int
asInt)
          , (Text -> ImagePiece) -> Maybe Text -> Maybe ImagePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> ImagePiece
ImageDescription (Maybe Text -> Maybe ImagePiece)
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe ImagePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"description" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          ]

-- | Parse a @\<category\>@ element.
rssCategory :: MonadThrow m => ConduitM Event o m (Maybe RssCategory)
rssCategory :: ConduitM Event o m (Maybe RssCategory)
rssCategory = Text
-> AttrParser (Maybe Text)
-> (Maybe Text -> ConduitM Event o m RssCategory)
-> ConduitM Event o m (Maybe RssCategory)
forall (m :: * -> *) a o b.
MonadThrow m =>
Text
-> AttrParser a
-> (a -> ConduitM Event o m b)
-> ConduitM Event o m (Maybe b)
tagName' Text
"category" (AttrParser Text -> AttrParser (Maybe Text)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Name -> AttrParser Text
requireAttr Name
"domain") AttrParser (Maybe Text) -> AttrParser () -> AttrParser (Maybe Text)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* AttrParser ()
ignoreAttrs) ((Maybe Text -> ConduitM Event o m RssCategory)
 -> ConduitM Event o m (Maybe RssCategory))
-> (Maybe Text -> ConduitM Event o m RssCategory)
-> ConduitM Event o m (Maybe RssCategory)
forall a b. (a -> b) -> a -> b
$ \Maybe Text
domain ->
  Text -> Text -> RssCategory
RssCategory (Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"" Maybe Text
domain) (Text -> RssCategory)
-> ConduitT Event o m Text -> ConduitM Event o m RssCategory
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content

-- | Parse a @\<cloud\>@ element.
rssCloud :: (MonadThrow m) => ConduitM Event o m (Maybe RssCloud)
rssCloud :: ConduitM Event o m (Maybe RssCloud)
rssCloud = Text
-> AttrParser RssCloud
-> (RssCloud -> ConduitM Event o m RssCloud)
-> ConduitM Event o m (Maybe RssCloud)
forall (m :: * -> *) a o b.
MonadThrow m =>
Text
-> AttrParser a
-> (a -> ConduitM Event o m b)
-> ConduitM Event o m (Maybe b)
tagName' Text
"cloud" AttrParser RssCloud
attributes RssCloud -> ConduitM Event o m RssCloud
forall (m :: * -> *) a. Monad m => a -> m a
return where
  attributes :: AttrParser RssCloud
attributes = do
    RssURI
uri <- (URIRef Relative -> RssURI)
-> AttrParser (URIRef Relative) -> AttrParser RssURI
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap URIRef Relative -> RssURI
forall a. URIRef a -> RssURI
RssURI (AttrParser (URIRef Relative) -> AttrParser RssURI)
-> AttrParser (URIRef Relative) -> AttrParser RssURI
forall a b. (a -> b) -> a -> b
$ Maybe Authority
-> ByteString -> Query -> Maybe ByteString -> URIRef Relative
RelativeRef
      (Maybe Authority
 -> ByteString -> Query -> Maybe ByteString -> URIRef Relative)
-> AttrParser (Maybe Authority)
-> AttrParser
     (ByteString -> Query -> Maybe ByteString -> URIRef Relative)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Authority -> Maybe Authority)
-> AttrParser Authority -> AttrParser (Maybe Authority)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Authority -> Maybe Authority
forall a. a -> Maybe a
Just (Maybe UserInfo -> Host -> Maybe Port -> Authority
Authority Maybe UserInfo
forall a. Maybe a
Nothing (Host -> Maybe Port -> Authority)
-> AttrParser Host -> AttrParser (Maybe Port -> Authority)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ByteString -> Host
Host (ByteString -> Host) -> (Text -> ByteString) -> Text -> Host
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ByteString
encodeUtf8 (Text -> Host) -> AttrParser Text -> AttrParser Host
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> AttrParser Text
requireAttr Name
"domain") AttrParser (Maybe Port -> Authority)
-> AttrParser (Maybe Port) -> AttrParser Authority
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((Int -> Port) -> Maybe Int -> Maybe Port
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Port
Port (Maybe Int -> Maybe Port)
-> AttrParser (Maybe Int) -> AttrParser (Maybe Port)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AttrParser Int -> AttrParser (Maybe Int)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Name -> AttrParser Text
requireAttr Name
"port" AttrParser Text -> (Text -> AttrParser Int) -> AttrParser Int
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> AttrParser Int
forall (m :: * -> *). MonadThrow m => Text -> m Int
asInt)))
      AttrParser
  (ByteString -> Query -> Maybe ByteString -> URIRef Relative)
-> AttrParser ByteString
-> AttrParser (Query -> Maybe ByteString -> URIRef Relative)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Text -> ByteString
encodeUtf8 (Text -> ByteString) -> AttrParser Text -> AttrParser ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> AttrParser Text
requireAttr Name
"path")
      AttrParser (Query -> Maybe ByteString -> URIRef Relative)
-> AttrParser Query
-> AttrParser (Maybe ByteString -> URIRef Relative)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Query -> AttrParser Query
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(ByteString, ByteString)] -> Query
Query [])
      AttrParser (Maybe ByteString -> URIRef Relative)
-> AttrParser (Maybe ByteString) -> AttrParser (URIRef Relative)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe ByteString -> AttrParser (Maybe ByteString)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe ByteString
forall a. Maybe a
Nothing
    RssURI -> Text -> CloudProtocol -> RssCloud
RssCloud RssURI
uri (Text -> CloudProtocol -> RssCloud)
-> AttrParser Text -> AttrParser (CloudProtocol -> RssCloud)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> AttrParser Text
requireAttr Name
"registerProcedure" AttrParser (CloudProtocol -> RssCloud)
-> AttrParser CloudProtocol -> AttrParser RssCloud
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Name -> AttrParser Text
requireAttr Name
"protocol" AttrParser Text
-> (Text -> AttrParser CloudProtocol) -> AttrParser CloudProtocol
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> AttrParser CloudProtocol
forall (m :: * -> *). MonadThrow m => Text -> m CloudProtocol
asCloudProtocol) AttrParser RssCloud -> AttrParser () -> AttrParser RssCloud
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* AttrParser ()
ignoreAttrs

-- | Parse a @\<guid\>@ element.
rssGuid :: MonadThrow m => ConduitM Event o m (Maybe RssGuid)
rssGuid :: ConduitM Event o m (Maybe RssGuid)
rssGuid = Text
-> AttrParser (Maybe Bool)
-> (Maybe Bool -> ConduitM Event o m RssGuid)
-> ConduitM Event o m (Maybe RssGuid)
forall (m :: * -> *) a o b.
MonadThrow m =>
Text
-> AttrParser a
-> (a -> ConduitM Event o m b)
-> ConduitM Event o m (Maybe b)
tagName' Text
"guid" AttrParser (Maybe Bool)
attributes Maybe Bool -> ConduitM Event o m RssGuid
forall (m :: * -> *) o.
MonadThrow m =>
Maybe Bool -> ConduitT Event o m RssGuid
handler where
  attributes :: AttrParser (Maybe Bool)
attributes = AttrParser Bool -> AttrParser (Maybe Bool)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Name -> AttrParser Text
requireAttr Name
"isPermaLink" AttrParser Text -> (Text -> AttrParser Bool) -> AttrParser Bool
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> AttrParser Bool
forall (m :: * -> *). MonadThrow m => Text -> m Bool
asBool) AttrParser (Maybe Bool) -> AttrParser () -> AttrParser (Maybe Bool)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* AttrParser ()
ignoreAttrs
  handler :: Maybe Bool -> ConduitT Event o m RssGuid
handler (Just Bool
True) = RssURI -> RssGuid
GuidUri (RssURI -> RssGuid)
-> ConduitT Event o m RssURI -> ConduitT Event o m RssGuid
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event o m Text
-> (Text -> ConduitT Event o m RssURI) -> ConduitT Event o m RssURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitT Event o m RssURI
forall (m :: * -> *). MonadThrow m => Text -> m RssURI
asRssURI)
  handler Maybe Bool
_           = Text -> RssGuid
GuidText (Text -> RssGuid)
-> ConduitT Event o m Text -> ConduitT Event o m RssGuid
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content

-- | Parse an @\<enclosure\>@ element.
rssEnclosure :: MonadThrow m => ConduitM Event o m (Maybe RssEnclosure)
rssEnclosure :: ConduitM Event o m (Maybe RssEnclosure)
rssEnclosure = Text
-> AttrParser (RssURI, Int, Text)
-> ((RssURI, Int, Text) -> ConduitM Event o m RssEnclosure)
-> ConduitM Event o m (Maybe RssEnclosure)
forall (m :: * -> *) a o b.
MonadThrow m =>
Text
-> AttrParser a
-> (a -> ConduitM Event o m b)
-> ConduitM Event o m (Maybe b)
tagName' Text
"enclosure" AttrParser (RssURI, Int, Text)
attributes (RssURI, Int, Text) -> ConduitM Event o m RssEnclosure
forall (m :: * -> *).
Monad m =>
(RssURI, Int, Text) -> m RssEnclosure
handler where
  attributes :: AttrParser (RssURI, Int, Text)
attributes = (,,) (RssURI -> Int -> Text -> (RssURI, Int, Text))
-> AttrParser RssURI
-> AttrParser (Int -> Text -> (RssURI, Int, Text))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Name -> AttrParser Text
requireAttr Name
"url" AttrParser Text -> (Text -> AttrParser RssURI) -> AttrParser RssURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> AttrParser RssURI
forall (m :: * -> *). MonadThrow m => Text -> m RssURI
asRssURI) AttrParser (Int -> Text -> (RssURI, Int, Text))
-> AttrParser Int -> AttrParser (Text -> (RssURI, Int, Text))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Name -> AttrParser Text
requireAttr Name
"length" AttrParser Text -> (Text -> AttrParser Int) -> AttrParser Int
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> AttrParser Int
forall (m :: * -> *). MonadThrow m => Text -> m Int
asInt) AttrParser (Text -> (RssURI, Int, Text))
-> AttrParser Text -> AttrParser (RssURI, Int, Text)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Name -> AttrParser Text
requireAttr Name
"type" AttrParser (RssURI, Int, Text)
-> AttrParser () -> AttrParser (RssURI, Int, Text)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* AttrParser ()
ignoreAttrs
  handler :: (RssURI, Int, Text) -> m RssEnclosure
handler (RssURI
uri, Int
length_, Text
type_) = RssEnclosure -> m RssEnclosure
forall (m :: * -> *) a. Monad m => a -> m a
return (RssEnclosure -> m RssEnclosure) -> RssEnclosure -> m RssEnclosure
forall a b. (a -> b) -> a -> b
$ RssURI -> Int -> Text -> RssEnclosure
RssEnclosure RssURI
uri Int
length_ Text
type_

-- | Parse a @\<source\>@ element.
rssSource :: MonadThrow m => ConduitM Event o m (Maybe RssSource)
rssSource :: ConduitM Event o m (Maybe RssSource)
rssSource = Text
-> AttrParser RssURI
-> (RssURI -> ConduitM Event o m RssSource)
-> ConduitM Event o m (Maybe RssSource)
forall (m :: * -> *) a o b.
MonadThrow m =>
Text
-> AttrParser a
-> (a -> ConduitM Event o m b)
-> ConduitM Event o m (Maybe b)
tagName' Text
"source" AttrParser RssURI
attributes RssURI -> ConduitM Event o m RssSource
forall (m :: * -> *) o.
MonadThrow m =>
RssURI -> ConduitT Event o m RssSource
handler where
  attributes :: AttrParser RssURI
attributes = (Name -> AttrParser Text
requireAttr Name
"url" AttrParser Text -> (Text -> AttrParser RssURI) -> AttrParser RssURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> AttrParser RssURI
forall (m :: * -> *). MonadThrow m => Text -> m RssURI
asRssURI) AttrParser RssURI -> AttrParser () -> AttrParser RssURI
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* AttrParser ()
ignoreAttrs
  handler :: RssURI -> ConduitT Event o m RssSource
handler RssURI
uri = RssURI -> Text -> RssSource
RssSource RssURI
uri (Text -> RssSource)
-> ConduitT Event o m Text -> ConduitT Event o m RssSource
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content


data ItemPiece = ItemTitle { ItemPiece -> Text
__itemTitle :: Text }
               | ItemLink { ItemPiece -> RssURI
__itemLink :: RssURI }
               | ItemDescription { ItemPiece -> Text
__itemDescription :: Text }
               | ItemAuthor { ItemPiece -> Text
__itemAuthor :: Text }
               | ItemCategory { ItemPiece -> RssCategory
__itemCategory :: RssCategory }
               | ItemComments { ItemPiece -> RssURI
__itemComments :: RssURI }
               | ItemEnclosure { ItemPiece -> RssEnclosure
__itemEnclosure :: RssEnclosure }
               | ItemGuid { ItemPiece -> RssGuid
__itemGuid :: RssGuid }
               | ItemPubDate { ItemPiece -> UTCTime
__itemPubDate :: UTCTime }
               | ItemSource { ItemPiece -> RssSource
__itemSource :: RssSource }
               | ItemOther { ItemPiece -> NonEmpty Event
__itemOther :: NonEmpty Event }

makeLenses ''ItemPiece

-- | Parse an @\<item\>@ element.
--
-- RSS extensions are automatically parsed based on the inferred result type.
rssItem :: ParseRssExtension e => MonadThrow m => ConduitM Event o m (Maybe (RssItem e))
rssItem :: ConduitM Event o m (Maybe (RssItem e))
rssItem = NameMatcher Name
-> ConduitT Event o m (RssItem e)
-> ConduitM Event o m (Maybe (RssItem e))
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"item" (ConduitT Event o m (RssItem e)
 -> ConduitM Event o m (Maybe (RssItem e)))
-> ConduitT Event o m (RssItem e)
-> ConduitM Event o m (Maybe (RssItem e))
forall a b. (a -> b) -> a -> b
$ (ConduitT Event ItemPiece m (Maybe ItemPiece)
-> ConduitT Event ItemPiece m ()
forall (m :: * -> *) b.
MonadThrow m =>
ConduitT Event b m (Maybe b) -> ConduitT Event b m ()
manyYield' ([ConduitT Event ItemPiece m (Maybe ItemPiece)]
-> ConduitT Event ItemPiece m (Maybe ItemPiece)
forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose [ConduitT Event ItemPiece m (Maybe ItemPiece)]
forall o. [ConduitT Event o m (Maybe ItemPiece)]
piece) ConduitT Event ItemPiece m ()
-> ConduitM ItemPiece o m (RssItem e)
-> ConduitT Event o m (RssItem e)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM ItemPiece o m (RssItem e)
forall o. ConduitT ItemPiece o m (RssItem e)
parser) ConduitT Event o m (RssItem e)
-> ConduitT Event o m [()] -> ConduitT Event o m (RssItem e)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ConduitT Event o m (Maybe ()) -> ConduitT Event o m [()]
forall (m :: * -> *) o a.
Monad m =>
ConduitT Event o m (Maybe a) -> ConduitT Event o m [a]
many ConduitT Event o m (Maybe ())
forall (m :: * -> *) o.
MonadThrow m =>
ConduitT Event o m (Maybe ())
ignoreAnyTreeContent where
  parser :: ConduitT ItemPiece o m (RssItem e)
parser = ZipConduit ItemPiece o m (RssItem e)
-> ConduitT ItemPiece o m (RssItem e)
forall i o (m :: * -> *) r. ZipConduit i o m r -> ConduitT i o m r
getZipConduit (ZipConduit ItemPiece o m (RssItem e)
 -> ConduitT ItemPiece o m (RssItem e))
-> ZipConduit ItemPiece o m (RssItem e)
-> ConduitT ItemPiece o m (RssItem e)
forall a b. (a -> b) -> a -> b
$ Text
-> Maybe RssURI
-> Text
-> Text
-> [RssCategory]
-> Maybe RssURI
-> [RssEnclosure]
-> Maybe RssGuid
-> Maybe UTCTime
-> Maybe RssSource
-> RssItemExtension e
-> RssItem e
forall extensions.
Text
-> Maybe RssURI
-> Text
-> Text
-> [RssCategory]
-> Maybe RssURI
-> [RssEnclosure]
-> Maybe RssGuid
-> Maybe UTCTime
-> Maybe RssSource
-> RssItemExtension extensions
-> RssItem extensions
RssItem
    (Text
 -> Maybe RssURI
 -> Text
 -> Text
 -> [RssCategory]
 -> Maybe RssURI
 -> [RssEnclosure]
 -> Maybe RssGuid
 -> Maybe UTCTime
 -> Maybe RssSource
 -> RssItemExtension e
 -> RssItem e)
-> ZipConduit ItemPiece o m Text
-> ZipConduit
     ItemPiece
     o
     m
     (Maybe RssURI
      -> Text
      -> Text
      -> [RssCategory]
      -> Maybe RssURI
      -> [RssEnclosure]
      -> Maybe RssGuid
      -> Maybe UTCTime
      -> Maybe RssSource
      -> RssItemExtension e
      -> RssItem e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT ItemPiece o m Text -> ZipConduit ItemPiece o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ItemPiece Text -> ConduitT ItemPiece Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ItemPiece Text
_itemTitle ConduitT ItemPiece Text m ()
-> ConduitM Text o m Text -> ConduitT ItemPiece o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a o. Monad m => a -> ConduitT a o m a
headDefC Text
"")
    ZipConduit
  ItemPiece
  o
  m
  (Maybe RssURI
   -> Text
   -> Text
   -> [RssCategory]
   -> Maybe RssURI
   -> [RssEnclosure]
   -> Maybe RssGuid
   -> Maybe UTCTime
   -> Maybe RssSource
   -> RssItemExtension e
   -> RssItem e)
-> ZipConduit ItemPiece o m (Maybe RssURI)
-> ZipConduit
     ItemPiece
     o
     m
     (Text
      -> Text
      -> [RssCategory]
      -> Maybe RssURI
      -> [RssEnclosure]
      -> Maybe RssGuid
      -> Maybe UTCTime
      -> Maybe RssSource
      -> RssItemExtension e
      -> RssItem e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT ItemPiece o m (Maybe RssURI)
-> ZipConduit ItemPiece o m (Maybe RssURI)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ItemPiece RssURI -> ConduitT ItemPiece RssURI m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ItemPiece RssURI
_itemLink ConduitT ItemPiece RssURI m ()
-> ConduitM RssURI o m (Maybe RssURI)
-> ConduitT ItemPiece o m (Maybe RssURI)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM RssURI o m (Maybe RssURI)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  ItemPiece
  o
  m
  (Text
   -> Text
   -> [RssCategory]
   -> Maybe RssURI
   -> [RssEnclosure]
   -> Maybe RssGuid
   -> Maybe UTCTime
   -> Maybe RssSource
   -> RssItemExtension e
   -> RssItem e)
-> ZipConduit ItemPiece o m Text
-> ZipConduit
     ItemPiece
     o
     m
     (Text
      -> [RssCategory]
      -> Maybe RssURI
      -> [RssEnclosure]
      -> Maybe RssGuid
      -> Maybe UTCTime
      -> Maybe RssSource
      -> RssItemExtension e
      -> RssItem e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT ItemPiece o m Text -> ZipConduit ItemPiece o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ItemPiece Text -> ConduitT ItemPiece Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ItemPiece Text
_itemDescription ConduitT ItemPiece Text m ()
-> ConduitM Text o m Text -> ConduitT ItemPiece o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a o. Monad m => a -> ConduitT a o m a
headDefC Text
"")
    ZipConduit
  ItemPiece
  o
  m
  (Text
   -> [RssCategory]
   -> Maybe RssURI
   -> [RssEnclosure]
   -> Maybe RssGuid
   -> Maybe UTCTime
   -> Maybe RssSource
   -> RssItemExtension e
   -> RssItem e)
-> ZipConduit ItemPiece o m Text
-> ZipConduit
     ItemPiece
     o
     m
     ([RssCategory]
      -> Maybe RssURI
      -> [RssEnclosure]
      -> Maybe RssGuid
      -> Maybe UTCTime
      -> Maybe RssSource
      -> RssItemExtension e
      -> RssItem e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT ItemPiece o m Text -> ZipConduit ItemPiece o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ItemPiece Text -> ConduitT ItemPiece Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ItemPiece Text
_itemAuthor ConduitT ItemPiece Text m ()
-> ConduitM Text o m Text -> ConduitT ItemPiece o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a o. Monad m => a -> ConduitT a o m a
headDefC Text
"")
    ZipConduit
  ItemPiece
  o
  m
  ([RssCategory]
   -> Maybe RssURI
   -> [RssEnclosure]
   -> Maybe RssGuid
   -> Maybe UTCTime
   -> Maybe RssSource
   -> RssItemExtension e
   -> RssItem e)
-> ZipConduit ItemPiece o m [RssCategory]
-> ZipConduit
     ItemPiece
     o
     m
     (Maybe RssURI
      -> [RssEnclosure]
      -> Maybe RssGuid
      -> Maybe UTCTime
      -> Maybe RssSource
      -> RssItemExtension e
      -> RssItem e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT ItemPiece o m [RssCategory]
-> ZipConduit ItemPiece o m [RssCategory]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ItemPiece RssCategory
-> ConduitT ItemPiece RssCategory m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ItemPiece RssCategory
_itemCategory ConduitT ItemPiece RssCategory m ()
-> ConduitM RssCategory o m [RssCategory]
-> ConduitT ItemPiece o m [RssCategory]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM RssCategory o m [RssCategory]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  ItemPiece
  o
  m
  (Maybe RssURI
   -> [RssEnclosure]
   -> Maybe RssGuid
   -> Maybe UTCTime
   -> Maybe RssSource
   -> RssItemExtension e
   -> RssItem e)
-> ZipConduit ItemPiece o m (Maybe RssURI)
-> ZipConduit
     ItemPiece
     o
     m
     ([RssEnclosure]
      -> Maybe RssGuid
      -> Maybe UTCTime
      -> Maybe RssSource
      -> RssItemExtension e
      -> RssItem e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT ItemPiece o m (Maybe RssURI)
-> ZipConduit ItemPiece o m (Maybe RssURI)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ItemPiece RssURI -> ConduitT ItemPiece RssURI m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ItemPiece RssURI
_itemComments ConduitT ItemPiece RssURI m ()
-> ConduitM RssURI o m (Maybe RssURI)
-> ConduitT ItemPiece o m (Maybe RssURI)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM RssURI o m (Maybe RssURI)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  ItemPiece
  o
  m
  ([RssEnclosure]
   -> Maybe RssGuid
   -> Maybe UTCTime
   -> Maybe RssSource
   -> RssItemExtension e
   -> RssItem e)
-> ZipConduit ItemPiece o m [RssEnclosure]
-> ZipConduit
     ItemPiece
     o
     m
     (Maybe RssGuid
      -> Maybe UTCTime
      -> Maybe RssSource
      -> RssItemExtension e
      -> RssItem e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT ItemPiece o m [RssEnclosure]
-> ZipConduit ItemPiece o m [RssEnclosure]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ItemPiece RssEnclosure
-> ConduitT ItemPiece RssEnclosure m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ItemPiece RssEnclosure
_itemEnclosure ConduitT ItemPiece RssEnclosure m ()
-> ConduitM RssEnclosure o m [RssEnclosure]
-> ConduitT ItemPiece o m [RssEnclosure]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM RssEnclosure o m [RssEnclosure]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  ItemPiece
  o
  m
  (Maybe RssGuid
   -> Maybe UTCTime
   -> Maybe RssSource
   -> RssItemExtension e
   -> RssItem e)
-> ZipConduit ItemPiece o m (Maybe RssGuid)
-> ZipConduit
     ItemPiece
     o
     m
     (Maybe UTCTime
      -> Maybe RssSource -> RssItemExtension e -> RssItem e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT ItemPiece o m (Maybe RssGuid)
-> ZipConduit ItemPiece o m (Maybe RssGuid)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ItemPiece RssGuid -> ConduitT ItemPiece RssGuid m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ItemPiece RssGuid
_itemGuid ConduitT ItemPiece RssGuid m ()
-> ConduitM RssGuid o m (Maybe RssGuid)
-> ConduitT ItemPiece o m (Maybe RssGuid)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM RssGuid o m (Maybe RssGuid)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  ItemPiece
  o
  m
  (Maybe UTCTime
   -> Maybe RssSource -> RssItemExtension e -> RssItem e)
-> ZipConduit ItemPiece o m (Maybe UTCTime)
-> ZipConduit
     ItemPiece o m (Maybe RssSource -> RssItemExtension e -> RssItem e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT ItemPiece o m (Maybe UTCTime)
-> ZipConduit ItemPiece o m (Maybe UTCTime)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ItemPiece UTCTime -> ConduitT ItemPiece UTCTime m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ItemPiece UTCTime
_itemPubDate ConduitT ItemPiece UTCTime m ()
-> ConduitM UTCTime o m (Maybe UTCTime)
-> ConduitT ItemPiece o m (Maybe UTCTime)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM UTCTime o m (Maybe UTCTime)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  ItemPiece o m (Maybe RssSource -> RssItemExtension e -> RssItem e)
-> ZipConduit ItemPiece o m (Maybe RssSource)
-> ZipConduit ItemPiece o m (RssItemExtension e -> RssItem e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT ItemPiece o m (Maybe RssSource)
-> ZipConduit ItemPiece o m (Maybe RssSource)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ItemPiece RssSource -> ConduitT ItemPiece RssSource m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ItemPiece RssSource
_itemSource ConduitT ItemPiece RssSource m ()
-> ConduitM RssSource o m (Maybe RssSource)
-> ConduitT ItemPiece o m (Maybe RssSource)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM RssSource o m (Maybe RssSource)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit ItemPiece o m (RssItemExtension e -> RssItem e)
-> ZipConduit ItemPiece o m (RssItemExtension e)
-> ZipConduit ItemPiece o m (RssItem e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT ItemPiece o m (RssItemExtension e)
-> ZipConduit ItemPiece o m (RssItemExtension e)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' ItemPiece (NonEmpty Event)
-> ConduitT ItemPiece (NonEmpty Event) m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' ItemPiece (NonEmpty Event)
_itemOther ConduitT ItemPiece (NonEmpty Event) m ()
-> ConduitM (NonEmpty Event) o m (RssItemExtension e)
-> ConduitT ItemPiece o m (RssItemExtension e)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitT (NonEmpty Event) Event m ()
forall (m :: * -> *) mono.
(Monad m, MonoFoldable mono) =>
ConduitT mono (Element mono) m ()
concatC ConduitT (NonEmpty Event) Event m ()
-> ConduitM Event o m (RssItemExtension e)
-> ConduitM (NonEmpty Event) o m (RssItemExtension e)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM Event o m (RssItemExtension e)
forall a (m :: * -> *) o.
(ParseRssExtension a, MonadThrow m) =>
ConduitT Event o m (RssItemExtension a)
parseRssItemExtension)
  piece :: [ConduitT Event o m (Maybe ItemPiece)]
piece = [ (Text -> ItemPiece) -> Maybe Text -> Maybe ItemPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> ItemPiece
ItemTitle (Maybe Text -> Maybe ItemPiece)
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe ItemPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"title" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (RssURI -> ItemPiece) -> Maybe RssURI -> Maybe ItemPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssURI -> ItemPiece
ItemLink (Maybe RssURI -> Maybe ItemPiece)
-> ConduitT Event o m (Maybe RssURI)
-> ConduitT Event o m (Maybe ItemPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m RssURI -> ConduitT Event o m (Maybe RssURI)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"link" (ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event o m Text
-> (Text -> ConduitT Event o m RssURI) -> ConduitT Event o m RssURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitT Event o m RssURI
forall (m :: * -> *). MonadThrow m => Text -> m RssURI
asRssURI)
          , (Text -> ItemPiece) -> Maybe Text -> Maybe ItemPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> ItemPiece
ItemDescription (Maybe Text -> Maybe ItemPiece)
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe ItemPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"description" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (Text -> ItemPiece) -> Maybe Text -> Maybe ItemPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> ItemPiece
ItemAuthor (Maybe Text -> Maybe ItemPiece)
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe ItemPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"author" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (RssCategory -> ItemPiece) -> Maybe RssCategory -> Maybe ItemPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssCategory -> ItemPiece
ItemCategory (Maybe RssCategory -> Maybe ItemPiece)
-> ConduitT Event o m (Maybe RssCategory)
-> ConduitT Event o m (Maybe ItemPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m (Maybe RssCategory)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe RssCategory)
rssCategory
          , (RssURI -> ItemPiece) -> Maybe RssURI -> Maybe ItemPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssURI -> ItemPiece
ItemComments (Maybe RssURI -> Maybe ItemPiece)
-> ConduitT Event o m (Maybe RssURI)
-> ConduitT Event o m (Maybe ItemPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m RssURI -> ConduitT Event o m (Maybe RssURI)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"comments" (ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event o m Text
-> (Text -> ConduitT Event o m RssURI) -> ConduitT Event o m RssURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitT Event o m RssURI
forall (m :: * -> *). MonadThrow m => Text -> m RssURI
asRssURI)
          , (RssEnclosure -> ItemPiece)
-> Maybe RssEnclosure -> Maybe ItemPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssEnclosure -> ItemPiece
ItemEnclosure (Maybe RssEnclosure -> Maybe ItemPiece)
-> ConduitT Event o m (Maybe RssEnclosure)
-> ConduitT Event o m (Maybe ItemPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m (Maybe RssEnclosure)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe RssEnclosure)
rssEnclosure
          , (RssGuid -> ItemPiece) -> Maybe RssGuid -> Maybe ItemPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssGuid -> ItemPiece
ItemGuid (Maybe RssGuid -> Maybe ItemPiece)
-> ConduitT Event o m (Maybe RssGuid)
-> ConduitT Event o m (Maybe ItemPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m (Maybe RssGuid)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe RssGuid)
rssGuid
          , (UTCTime -> ItemPiece) -> Maybe UTCTime -> Maybe ItemPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap UTCTime -> ItemPiece
ItemPubDate (Maybe UTCTime -> Maybe ItemPiece)
-> ConduitT Event o m (Maybe UTCTime)
-> ConduitT Event o m (Maybe ItemPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name -> ConduitT Event o m (Maybe UTCTime)
forall (m :: * -> *) a o.
MonadThrow m =>
NameMatcher a -> ConduitM Event o m (Maybe UTCTime)
tagDate NameMatcher Name
"pubDate"
          , (RssSource -> ItemPiece) -> Maybe RssSource -> Maybe ItemPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssSource -> ItemPiece
ItemSource (Maybe RssSource -> Maybe ItemPiece)
-> ConduitT Event o m (Maybe RssSource)
-> ConduitT Event o m (Maybe ItemPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m (Maybe RssSource)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe RssSource)
rssSource
          , (NonEmpty Event -> ItemPiece)
-> Maybe (NonEmpty Event) -> Maybe ItemPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap NonEmpty Event -> ItemPiece
ItemOther (Maybe (NonEmpty Event) -> Maybe ItemPiece)
-> ([Event] -> Maybe (NonEmpty Event))
-> [Event]
-> Maybe ItemPiece
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Event] -> Maybe (NonEmpty Event)
forall a. [a] -> Maybe (NonEmpty a)
nonEmpty ([Event] -> Maybe ItemPiece)
-> ConduitT Event o m [Event]
-> ConduitT Event o m (Maybe ItemPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ConduitT Event Event m (Maybe ()) -> ConduitT Event Event m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ConduitT Event Event m (Maybe ())
forall (m :: * -> *).
MonadThrow m =>
ConduitT Event Event m (Maybe ())
takeAnyTreeContent ConduitT Event Event m ()
-> ConduitT Event o m [Event] -> ConduitT Event o m [Event]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitT Event o m [Event]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
          ]


data ChannelPiece e = ChannelTitle { ChannelPiece e -> Text
__channelTitle :: Text }
                    | ChannelLink { ChannelPiece e -> RssURI
__channelLink :: RssURI }
                    | ChannelDescription { ChannelPiece e -> Text
__channelDescription :: Text }
                    | ChannelItem { ChannelPiece e -> RssItem e
__channelItem :: RssItem e }
                    | ChannelLanguage { ChannelPiece e -> Text
__channelLanguage :: Text }
                    | ChannelCopyright { ChannelPiece e -> Text
__channelCopyright :: Text }
                    | ChannelManagingEditor { ChannelPiece e -> Text
__channelManagingEditor :: Text }
                    | ChannelWebmaster { ChannelPiece e -> Text
__channelWebmaster :: Text }
                    | ChannelPubDate { ChannelPiece e -> UTCTime
__channelPubDate :: UTCTime }
                    | ChannelLastBuildDate { ChannelPiece e -> UTCTime
__channelLastBuildDate :: UTCTime }
                    | ChannelCategory { ChannelPiece e -> RssCategory
__channelCategory :: RssCategory }
                    | ChannelGenerator { ChannelPiece e -> Text
__channelGenerator :: Text }
                    | ChannelDocs { ChannelPiece e -> RssURI
__channelDocs :: RssURI }
                    | ChannelCloud { ChannelPiece e -> RssCloud
__channelCloud :: RssCloud }
                    | ChannelTtl { ChannelPiece e -> Int
__channelTtl :: Int }
                    | ChannelImage { ChannelPiece e -> RssImage
__channelImage :: RssImage }
                    | ChannelRating { ChannelPiece e -> Text
__channelRating :: Text }
                    | ChannelTextInput { ChannelPiece e -> RssTextInput
__channelTextInput :: RssTextInput }
                    | ChannelSkipHours { ChannelPiece e -> Set Hour
__channelSkipHours :: Set Hour }
                    | ChannelSkipDays { ChannelPiece e -> Set Day
__channelSkipDays :: Set Day }
                    | ChannelOther { ChannelPiece e -> NonEmpty Event
__channelOther :: NonEmpty Event }

makeLenses ''ChannelPiece

-- | Parse an @\<rss\>@ element.
--
-- RSS extensions are automatically parsed based on the inferred result type.
rssDocument :: ParseRssExtension e => MonadThrow m => ConduitM Event o m (Maybe (RssDocument e))
rssDocument :: ConduitM Event o m (Maybe (RssDocument e))
rssDocument = Text
-> AttrParser Version
-> (Version -> ConduitM Event o m (RssDocument e))
-> ConduitM Event o m (Maybe (RssDocument e))
forall (m :: * -> *) a o b.
MonadThrow m =>
Text
-> AttrParser a
-> (a -> ConduitM Event o m b)
-> ConduitM Event o m (Maybe b)
tagName' Text
"rss" AttrParser Version
attributes ((Version -> ConduitM Event o m (RssDocument e))
 -> ConduitM Event o m (Maybe (RssDocument e)))
-> (Version -> ConduitM Event o m (RssDocument e))
-> ConduitM Event o m (Maybe (RssDocument e))
forall a b. (a -> b) -> a -> b
$ \Version
version -> String
-> ConduitM Event o m (Maybe (RssDocument e))
-> ConduitM Event o m (RssDocument e)
forall (m :: * -> *) a.
MonadThrow m =>
String -> m (Maybe a) -> m a
force String
"Missing <channel>" (ConduitM Event o m (Maybe (RssDocument e))
 -> ConduitM Event o m (RssDocument e))
-> ConduitM Event o m (Maybe (RssDocument e))
-> ConduitM Event o m (RssDocument e)
forall a b. (a -> b) -> a -> b
$ NameMatcher Name
-> ConduitM Event o m (RssDocument e)
-> ConduitM Event o m (Maybe (RssDocument e))
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"channel" (ConduitT Event (ChannelPiece e) m (Maybe (ChannelPiece e))
-> ConduitT Event (ChannelPiece e) m ()
forall (m :: * -> *) b.
MonadThrow m =>
ConduitT Event b m (Maybe b) -> ConduitT Event b m ()
manyYield' ([ConduitT Event (ChannelPiece e) m (Maybe (ChannelPiece e))]
-> ConduitT Event (ChannelPiece e) m (Maybe (ChannelPiece e))
forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose [ConduitT Event (ChannelPiece e) m (Maybe (ChannelPiece e))]
forall o. [ConduitT Event o m (Maybe (ChannelPiece e))]
piece) ConduitT Event (ChannelPiece e) m ()
-> ConduitM (ChannelPiece e) o m (RssDocument e)
-> ConduitM Event o m (RssDocument e)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Version -> ConduitM (ChannelPiece e) o m (RssDocument e)
forall (m :: * -> *) e o.
(MonadThrow m, ParseRssExtension e) =>
Version -> ConduitT (ChannelPiece e) o m (RssDocument e)
parser Version
version) ConduitM Event o m (Maybe (RssDocument e))
-> ConduitT Event o m [()]
-> ConduitM Event o m (Maybe (RssDocument e))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ConduitT Event o m (Maybe ()) -> ConduitT Event o m [()]
forall (m :: * -> *) o a.
Monad m =>
ConduitT Event o m (Maybe a) -> ConduitT Event o m [a]
many ConduitT Event o m (Maybe ())
forall (m :: * -> *) o.
MonadThrow m =>
ConduitT Event o m (Maybe ())
ignoreAnyTreeContent where
  parser :: Version -> ConduitT (ChannelPiece e) o m (RssDocument e)
parser Version
version = ZipConduit (ChannelPiece e) o m (RssDocument e)
-> ConduitT (ChannelPiece e) o m (RssDocument e)
forall i o (m :: * -> *) r. ZipConduit i o m r -> ConduitT i o m r
getZipConduit (ZipConduit (ChannelPiece e) o m (RssDocument e)
 -> ConduitT (ChannelPiece e) o m (RssDocument e))
-> ZipConduit (ChannelPiece e) o m (RssDocument e)
-> ConduitT (ChannelPiece e) o m (RssDocument e)
forall a b. (a -> b) -> a -> b
$ Version
-> Text
-> RssURI
-> Text
-> [RssItem e]
-> Text
-> Text
-> Text
-> Text
-> Maybe UTCTime
-> Maybe UTCTime
-> [RssCategory]
-> Text
-> Maybe RssURI
-> Maybe RssCloud
-> Maybe Int
-> Maybe RssImage
-> Text
-> Maybe RssTextInput
-> Set Hour
-> Set Day
-> RssChannelExtension e
-> RssDocument e
forall extensions.
Version
-> Text
-> RssURI
-> Text
-> [RssItem extensions]
-> Text
-> Text
-> Text
-> Text
-> Maybe UTCTime
-> Maybe UTCTime
-> [RssCategory]
-> Text
-> Maybe RssURI
-> Maybe RssCloud
-> Maybe Int
-> Maybe RssImage
-> Text
-> Maybe RssTextInput
-> Set Hour
-> Set Day
-> RssChannelExtension extensions
-> RssDocument extensions
RssDocument Version
version
    (Text
 -> RssURI
 -> Text
 -> [RssItem e]
 -> Text
 -> Text
 -> Text
 -> Text
 -> Maybe UTCTime
 -> Maybe UTCTime
 -> [RssCategory]
 -> Text
 -> Maybe RssURI
 -> Maybe RssCloud
 -> Maybe Int
 -> Maybe RssImage
 -> Text
 -> Maybe RssTextInput
 -> Set Hour
 -> Set Day
 -> RssChannelExtension e
 -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m Text
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (RssURI
      -> Text
      -> [RssItem e]
      -> Text
      -> Text
      -> Text
      -> Text
      -> Maybe UTCTime
      -> Maybe UTCTime
      -> [RssCategory]
      -> Text
      -> Maybe RssURI
      -> Maybe RssCloud
      -> Maybe Int
      -> Maybe RssImage
      -> Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT (ChannelPiece e) o m Text
-> ZipConduit (ChannelPiece e) o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) Text
-> ConduitT (ChannelPiece e) Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) Text
Traversal' (ChannelPiece e) Text
_channelTitle ConduitT (ChannelPiece e) Text m ()
-> ConduitM Text o m Text -> ConduitT (ChannelPiece e) o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a b. MonadThrow m => Text -> ConduitT a b m a
headRequiredC Text
"Missing <title> element")
    ZipConduit
  (ChannelPiece e)
  o
  m
  (RssURI
   -> Text
   -> [RssItem e]
   -> Text
   -> Text
   -> Text
   -> Text
   -> Maybe UTCTime
   -> Maybe UTCTime
   -> [RssCategory]
   -> Text
   -> Maybe RssURI
   -> Maybe RssCloud
   -> Maybe Int
   -> Maybe RssImage
   -> Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m RssURI
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Text
      -> [RssItem e]
      -> Text
      -> Text
      -> Text
      -> Text
      -> Maybe UTCTime
      -> Maybe UTCTime
      -> [RssCategory]
      -> Text
      -> Maybe RssURI
      -> Maybe RssCloud
      -> Maybe Int
      -> Maybe RssImage
      -> Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m RssURI
-> ZipConduit (ChannelPiece e) o m RssURI
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) RssURI
-> ConduitT (ChannelPiece e) RssURI m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) RssURI
Traversal' (ChannelPiece e) RssURI
_channelLink ConduitT (ChannelPiece e) RssURI m ()
-> ConduitM RssURI o m RssURI
-> ConduitT (ChannelPiece e) o m RssURI
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM RssURI o m RssURI
forall (m :: * -> *) a b. MonadThrow m => Text -> ConduitT a b m a
headRequiredC Text
"Missing <link> element")
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Text
   -> [RssItem e]
   -> Text
   -> Text
   -> Text
   -> Text
   -> Maybe UTCTime
   -> Maybe UTCTime
   -> [RssCategory]
   -> Text
   -> Maybe RssURI
   -> Maybe RssCloud
   -> Maybe Int
   -> Maybe RssImage
   -> Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m Text
-> ZipConduit
     (ChannelPiece e)
     o
     m
     ([RssItem e]
      -> Text
      -> Text
      -> Text
      -> Text
      -> Maybe UTCTime
      -> Maybe UTCTime
      -> [RssCategory]
      -> Text
      -> Maybe RssURI
      -> Maybe RssCloud
      -> Maybe Int
      -> Maybe RssImage
      -> Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m Text
-> ZipConduit (ChannelPiece e) o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) Text
-> ConduitT (ChannelPiece e) Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) Text
Traversal' (ChannelPiece e) Text
_channelDescription ConduitT (ChannelPiece e) Text m ()
-> ConduitM Text o m Text -> ConduitT (ChannelPiece e) o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a o. Monad m => a -> ConduitT a o m a
headDefC Text
"")  -- Lenient
    ZipConduit
  (ChannelPiece e)
  o
  m
  ([RssItem e]
   -> Text
   -> Text
   -> Text
   -> Text
   -> Maybe UTCTime
   -> Maybe UTCTime
   -> [RssCategory]
   -> Text
   -> Maybe RssURI
   -> Maybe RssCloud
   -> Maybe Int
   -> Maybe RssImage
   -> Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m [RssItem e]
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Text
      -> Text
      -> Text
      -> Text
      -> Maybe UTCTime
      -> Maybe UTCTime
      -> [RssCategory]
      -> Text
      -> Maybe RssURI
      -> Maybe RssCloud
      -> Maybe Int
      -> Maybe RssImage
      -> Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m [RssItem e]
-> ZipConduit (ChannelPiece e) o m [RssItem e]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) (RssItem e)
-> ConduitT (ChannelPiece e) (RssItem e) m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e e.
Traversal (ChannelPiece e) (ChannelPiece e) (RssItem e) (RssItem e)
Traversal' (ChannelPiece e) (RssItem e)
_channelItem ConduitT (ChannelPiece e) (RssItem e) m ()
-> ConduitM (RssItem e) o m [RssItem e]
-> ConduitT (ChannelPiece e) o m [RssItem e]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM (RssItem e) o m [RssItem e]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Text
   -> Text
   -> Text
   -> Text
   -> Maybe UTCTime
   -> Maybe UTCTime
   -> [RssCategory]
   -> Text
   -> Maybe RssURI
   -> Maybe RssCloud
   -> Maybe Int
   -> Maybe RssImage
   -> Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m Text
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Text
      -> Text
      -> Text
      -> Maybe UTCTime
      -> Maybe UTCTime
      -> [RssCategory]
      -> Text
      -> Maybe RssURI
      -> Maybe RssCloud
      -> Maybe Int
      -> Maybe RssImage
      -> Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m Text
-> ZipConduit (ChannelPiece e) o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) Text
-> ConduitT (ChannelPiece e) Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) Text
Traversal' (ChannelPiece e) Text
_channelLanguage ConduitT (ChannelPiece e) Text m ()
-> ConduitM Text o m Text -> ConduitT (ChannelPiece e) o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a o. Monad m => a -> ConduitT a o m a
headDefC Text
"")
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Text
   -> Text
   -> Text
   -> Maybe UTCTime
   -> Maybe UTCTime
   -> [RssCategory]
   -> Text
   -> Maybe RssURI
   -> Maybe RssCloud
   -> Maybe Int
   -> Maybe RssImage
   -> Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m Text
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Text
      -> Text
      -> Maybe UTCTime
      -> Maybe UTCTime
      -> [RssCategory]
      -> Text
      -> Maybe RssURI
      -> Maybe RssCloud
      -> Maybe Int
      -> Maybe RssImage
      -> Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m Text
-> ZipConduit (ChannelPiece e) o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) Text
-> ConduitT (ChannelPiece e) Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) Text
Traversal' (ChannelPiece e) Text
_channelCopyright ConduitT (ChannelPiece e) Text m ()
-> ConduitM Text o m Text -> ConduitT (ChannelPiece e) o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a o. Monad m => a -> ConduitT a o m a
headDefC Text
"")
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Text
   -> Text
   -> Maybe UTCTime
   -> Maybe UTCTime
   -> [RssCategory]
   -> Text
   -> Maybe RssURI
   -> Maybe RssCloud
   -> Maybe Int
   -> Maybe RssImage
   -> Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m Text
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Text
      -> Maybe UTCTime
      -> Maybe UTCTime
      -> [RssCategory]
      -> Text
      -> Maybe RssURI
      -> Maybe RssCloud
      -> Maybe Int
      -> Maybe RssImage
      -> Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m Text
-> ZipConduit (ChannelPiece e) o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) Text
-> ConduitT (ChannelPiece e) Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) Text
Traversal' (ChannelPiece e) Text
_channelManagingEditor ConduitT (ChannelPiece e) Text m ()
-> ConduitM Text o m Text -> ConduitT (ChannelPiece e) o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a o. Monad m => a -> ConduitT a o m a
headDefC Text
"")
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Text
   -> Maybe UTCTime
   -> Maybe UTCTime
   -> [RssCategory]
   -> Text
   -> Maybe RssURI
   -> Maybe RssCloud
   -> Maybe Int
   -> Maybe RssImage
   -> Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m Text
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Maybe UTCTime
      -> Maybe UTCTime
      -> [RssCategory]
      -> Text
      -> Maybe RssURI
      -> Maybe RssCloud
      -> Maybe Int
      -> Maybe RssImage
      -> Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m Text
-> ZipConduit (ChannelPiece e) o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) Text
-> ConduitT (ChannelPiece e) Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) Text
Traversal' (ChannelPiece e) Text
_channelWebmaster ConduitT (ChannelPiece e) Text m ()
-> ConduitM Text o m Text -> ConduitT (ChannelPiece e) o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a o. Monad m => a -> ConduitT a o m a
headDefC Text
"")
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Maybe UTCTime
   -> Maybe UTCTime
   -> [RssCategory]
   -> Text
   -> Maybe RssURI
   -> Maybe RssCloud
   -> Maybe Int
   -> Maybe RssImage
   -> Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m (Maybe UTCTime)
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Maybe UTCTime
      -> [RssCategory]
      -> Text
      -> Maybe RssURI
      -> Maybe RssCloud
      -> Maybe Int
      -> Maybe RssImage
      -> Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m (Maybe UTCTime)
-> ZipConduit (ChannelPiece e) o m (Maybe UTCTime)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) UTCTime
-> ConduitT (ChannelPiece e) UTCTime m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) UTCTime
Traversal' (ChannelPiece e) UTCTime
_channelPubDate ConduitT (ChannelPiece e) UTCTime m ()
-> ConduitM UTCTime o m (Maybe UTCTime)
-> ConduitT (ChannelPiece e) o m (Maybe UTCTime)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM UTCTime o m (Maybe UTCTime)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Maybe UTCTime
   -> [RssCategory]
   -> Text
   -> Maybe RssURI
   -> Maybe RssCloud
   -> Maybe Int
   -> Maybe RssImage
   -> Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m (Maybe UTCTime)
-> ZipConduit
     (ChannelPiece e)
     o
     m
     ([RssCategory]
      -> Text
      -> Maybe RssURI
      -> Maybe RssCloud
      -> Maybe Int
      -> Maybe RssImage
      -> Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m (Maybe UTCTime)
-> ZipConduit (ChannelPiece e) o m (Maybe UTCTime)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) UTCTime
-> ConduitT (ChannelPiece e) UTCTime m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) UTCTime
Traversal' (ChannelPiece e) UTCTime
_channelLastBuildDate ConduitT (ChannelPiece e) UTCTime m ()
-> ConduitM UTCTime o m (Maybe UTCTime)
-> ConduitT (ChannelPiece e) o m (Maybe UTCTime)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM UTCTime o m (Maybe UTCTime)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  (ChannelPiece e)
  o
  m
  ([RssCategory]
   -> Text
   -> Maybe RssURI
   -> Maybe RssCloud
   -> Maybe Int
   -> Maybe RssImage
   -> Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m [RssCategory]
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Text
      -> Maybe RssURI
      -> Maybe RssCloud
      -> Maybe Int
      -> Maybe RssImage
      -> Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m [RssCategory]
-> ZipConduit (ChannelPiece e) o m [RssCategory]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) RssCategory
-> ConduitT (ChannelPiece e) RssCategory m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) RssCategory
Traversal' (ChannelPiece e) RssCategory
_channelCategory ConduitT (ChannelPiece e) RssCategory m ()
-> ConduitM RssCategory o m [RssCategory]
-> ConduitT (ChannelPiece e) o m [RssCategory]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM RssCategory o m [RssCategory]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Text
   -> Maybe RssURI
   -> Maybe RssCloud
   -> Maybe Int
   -> Maybe RssImage
   -> Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m Text
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Maybe RssURI
      -> Maybe RssCloud
      -> Maybe Int
      -> Maybe RssImage
      -> Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m Text
-> ZipConduit (ChannelPiece e) o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) Text
-> ConduitT (ChannelPiece e) Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) Text
Traversal' (ChannelPiece e) Text
_channelGenerator ConduitT (ChannelPiece e) Text m ()
-> ConduitM Text o m Text -> ConduitT (ChannelPiece e) o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a o. Monad m => a -> ConduitT a o m a
headDefC Text
"")
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Maybe RssURI
   -> Maybe RssCloud
   -> Maybe Int
   -> Maybe RssImage
   -> Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m (Maybe RssURI)
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Maybe RssCloud
      -> Maybe Int
      -> Maybe RssImage
      -> Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m (Maybe RssURI)
-> ZipConduit (ChannelPiece e) o m (Maybe RssURI)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) RssURI
-> ConduitT (ChannelPiece e) RssURI m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) RssURI
Traversal' (ChannelPiece e) RssURI
_channelDocs ConduitT (ChannelPiece e) RssURI m ()
-> ConduitM RssURI o m (Maybe RssURI)
-> ConduitT (ChannelPiece e) o m (Maybe RssURI)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM RssURI o m (Maybe RssURI)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Maybe RssCloud
   -> Maybe Int
   -> Maybe RssImage
   -> Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m (Maybe RssCloud)
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Maybe Int
      -> Maybe RssImage
      -> Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m (Maybe RssCloud)
-> ZipConduit (ChannelPiece e) o m (Maybe RssCloud)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) RssCloud
-> ConduitT (ChannelPiece e) RssCloud m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) RssCloud
Traversal' (ChannelPiece e) RssCloud
_channelCloud ConduitT (ChannelPiece e) RssCloud m ()
-> ConduitM RssCloud o m (Maybe RssCloud)
-> ConduitT (ChannelPiece e) o m (Maybe RssCloud)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM RssCloud o m (Maybe RssCloud)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Maybe Int
   -> Maybe RssImage
   -> Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m (Maybe Int)
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Maybe RssImage
      -> Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m (Maybe Int)
-> ZipConduit (ChannelPiece e) o m (Maybe Int)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) Int
-> ConduitT (ChannelPiece e) Int m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) Int
Traversal' (ChannelPiece e) Int
_channelTtl ConduitT (ChannelPiece e) Int m ()
-> ConduitM Int o m (Maybe Int)
-> ConduitT (ChannelPiece e) o m (Maybe Int)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM Int o m (Maybe Int)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Maybe RssImage
   -> Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m (Maybe RssImage)
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Text
      -> Maybe RssTextInput
      -> Set Hour
      -> Set Day
      -> RssChannelExtension e
      -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m (Maybe RssImage)
-> ZipConduit (ChannelPiece e) o m (Maybe RssImage)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) RssImage
-> ConduitT (ChannelPiece e) RssImage m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) RssImage
Traversal' (ChannelPiece e) RssImage
_channelImage ConduitT (ChannelPiece e) RssImage m ()
-> ConduitM RssImage o m (Maybe RssImage)
-> ConduitT (ChannelPiece e) o m (Maybe RssImage)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM RssImage o m (Maybe RssImage)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Text
   -> Maybe RssTextInput
   -> Set Hour
   -> Set Day
   -> RssChannelExtension e
   -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m Text
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Maybe RssTextInput
      -> Set Hour -> Set Day -> RssChannelExtension e -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m Text
-> ZipConduit (ChannelPiece e) o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) Text
-> ConduitT (ChannelPiece e) Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) Text
Traversal' (ChannelPiece e) Text
_channelRating ConduitT (ChannelPiece e) Text m ()
-> ConduitM Text o m Text -> ConduitT (ChannelPiece e) o m Text
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM Text o m Text
forall (m :: * -> *) a o. Monad m => a -> ConduitT a o m a
headDefC Text
"")
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Maybe RssTextInput
   -> Set Hour -> Set Day -> RssChannelExtension e -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m (Maybe RssTextInput)
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Set Hour -> Set Day -> RssChannelExtension e -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m (Maybe RssTextInput)
-> ZipConduit (ChannelPiece e) o m (Maybe RssTextInput)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) RssTextInput
-> ConduitT (ChannelPiece e) RssTextInput m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) RssTextInput
Traversal' (ChannelPiece e) RssTextInput
_channelTextInput ConduitT (ChannelPiece e) RssTextInput m ()
-> ConduitM RssTextInput o m (Maybe RssTextInput)
-> ConduitT (ChannelPiece e) o m (Maybe RssTextInput)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM RssTextInput o m (Maybe RssTextInput)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Set Hour -> Set Day -> RssChannelExtension e -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m (Set Hour)
-> ZipConduit
     (ChannelPiece e)
     o
     m
     (Set Day -> RssChannelExtension e -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m (Set Hour)
-> ZipConduit (ChannelPiece e) o m (Set Hour)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) (Set Hour)
-> ConduitT (ChannelPiece e) (Set Hour) m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) (Set Hour)
Traversal' (ChannelPiece e) (Set Hour)
_channelSkipHours ConduitT (ChannelPiece e) (Set Hour) m ()
-> ConduitM (Set Hour) o m (Set Hour)
-> ConduitT (ChannelPiece e) o m (Set Hour)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Set Hour -> ConduitM (Set Hour) o m (Set Hour)
forall (m :: * -> *) a o. Monad m => a -> ConduitT a o m a
headDefC Set Hour
forall a. Monoid a => a
mempty)
    ZipConduit
  (ChannelPiece e)
  o
  m
  (Set Day -> RssChannelExtension e -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m (Set Day)
-> ZipConduit
     (ChannelPiece e) o m (RssChannelExtension e -> RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m (Set Day)
-> ZipConduit (ChannelPiece e) o m (Set Day)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) (Set Day)
-> ConduitT (ChannelPiece e) (Set Day) m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) (Set Day)
Traversal' (ChannelPiece e) (Set Day)
_channelSkipDays ConduitT (ChannelPiece e) (Set Day) m ()
-> ConduitM (Set Day) o m (Set Day)
-> ConduitT (ChannelPiece e) o m (Set Day)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Set Day -> ConduitM (Set Day) o m (Set Day)
forall (m :: * -> *) a o. Monad m => a -> ConduitT a o m a
headDefC Set Day
forall a. Monoid a => a
mempty)
    ZipConduit
  (ChannelPiece e) o m (RssChannelExtension e -> RssDocument e)
-> ZipConduit (ChannelPiece e) o m (RssChannelExtension e)
-> ZipConduit (ChannelPiece e) o m (RssDocument e)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT (ChannelPiece e) o m (RssChannelExtension e)
-> ZipConduit (ChannelPiece e) o m (RssChannelExtension e)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' (ChannelPiece e) (NonEmpty Event)
-> ConduitT (ChannelPiece e) (NonEmpty Event) m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC forall e. Traversal' (ChannelPiece e) (NonEmpty Event)
Traversal' (ChannelPiece e) (NonEmpty Event)
_channelOther ConduitT (ChannelPiece e) (NonEmpty Event) m ()
-> ConduitM (NonEmpty Event) o m (RssChannelExtension e)
-> ConduitT (ChannelPiece e) o m (RssChannelExtension e)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitT (NonEmpty Event) Event m ()
forall (m :: * -> *) mono.
(Monad m, MonoFoldable mono) =>
ConduitT mono (Element mono) m ()
concatC ConduitT (NonEmpty Event) Event m ()
-> ConduitM Event o m (RssChannelExtension e)
-> ConduitM (NonEmpty Event) o m (RssChannelExtension e)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM Event o m (RssChannelExtension e)
forall a (m :: * -> *) o.
(ParseRssExtension a, MonadThrow m) =>
ConduitT Event o m (RssChannelExtension a)
parseRssChannelExtension)
  piece :: [ConduitT Event o m (Maybe (ChannelPiece e))]
piece = [ (Text -> ChannelPiece e) -> Maybe Text -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> ChannelPiece e
forall e. Text -> ChannelPiece e
ChannelTitle (Maybe Text -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"title" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (RssURI -> ChannelPiece e)
-> Maybe RssURI -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssURI -> ChannelPiece e
forall e. RssURI -> ChannelPiece e
ChannelLink (Maybe RssURI -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe RssURI)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m RssURI -> ConduitT Event o m (Maybe RssURI)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"link" (ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event o m Text
-> (Text -> ConduitT Event o m RssURI) -> ConduitT Event o m RssURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitT Event o m RssURI
forall (m :: * -> *). MonadThrow m => Text -> m RssURI
asRssURI)
          , (Text -> ChannelPiece e) -> Maybe Text -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> ChannelPiece e
forall e. Text -> ChannelPiece e
ChannelDescription (Maybe Text -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"description" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (RssItem e -> ChannelPiece e)
-> Maybe (RssItem e) -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssItem e -> ChannelPiece e
forall e. RssItem e -> ChannelPiece e
ChannelItem (Maybe (RssItem e) -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe (RssItem e))
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m (Maybe (RssItem e))
forall e (m :: * -> *) o.
(ParseRssExtension e, MonadThrow m) =>
ConduitM Event o m (Maybe (RssItem e))
rssItem
          , (Text -> ChannelPiece e) -> Maybe Text -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> ChannelPiece e
forall e. Text -> ChannelPiece e
ChannelLanguage (Maybe Text -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"language" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (Text -> ChannelPiece e) -> Maybe Text -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> ChannelPiece e
forall e. Text -> ChannelPiece e
ChannelCopyright (Maybe Text -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"copyright" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (Text -> ChannelPiece e) -> Maybe Text -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> ChannelPiece e
forall e. Text -> ChannelPiece e
ChannelManagingEditor (Maybe Text -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"managingEditor" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (Text -> ChannelPiece e) -> Maybe Text -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> ChannelPiece e
forall e. Text -> ChannelPiece e
ChannelWebmaster (Maybe Text -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"webMaster" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (UTCTime -> ChannelPiece e)
-> Maybe UTCTime -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap UTCTime -> ChannelPiece e
forall e. UTCTime -> ChannelPiece e
ChannelPubDate (Maybe UTCTime -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe UTCTime)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name -> ConduitT Event o m (Maybe UTCTime)
forall (m :: * -> *) a o.
MonadThrow m =>
NameMatcher a -> ConduitM Event o m (Maybe UTCTime)
tagDate NameMatcher Name
"pubDate"
          , (UTCTime -> ChannelPiece e)
-> Maybe UTCTime -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap UTCTime -> ChannelPiece e
forall e. UTCTime -> ChannelPiece e
ChannelLastBuildDate (Maybe UTCTime -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe UTCTime)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name -> ConduitT Event o m (Maybe UTCTime)
forall (m :: * -> *) a o.
MonadThrow m =>
NameMatcher a -> ConduitM Event o m (Maybe UTCTime)
tagDate NameMatcher Name
"lastBuildDate"
          , (RssCategory -> ChannelPiece e)
-> Maybe RssCategory -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssCategory -> ChannelPiece e
forall e. RssCategory -> ChannelPiece e
ChannelCategory (Maybe RssCategory -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe RssCategory)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m (Maybe RssCategory)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe RssCategory)
rssCategory
          , (Text -> ChannelPiece e) -> Maybe Text -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> ChannelPiece e
forall e. Text -> ChannelPiece e
ChannelGenerator (Maybe Text -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"generator" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (RssURI -> ChannelPiece e)
-> Maybe RssURI -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssURI -> ChannelPiece e
forall e. RssURI -> ChannelPiece e
ChannelDocs (Maybe RssURI -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe RssURI)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m RssURI -> ConduitT Event o m (Maybe RssURI)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"docs" (ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event o m Text
-> (Text -> ConduitT Event o m RssURI) -> ConduitT Event o m RssURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitT Event o m RssURI
forall (m :: * -> *). MonadThrow m => Text -> m RssURI
asRssURI)
          , (RssCloud -> ChannelPiece e)
-> Maybe RssCloud -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssCloud -> ChannelPiece e
forall e. RssCloud -> ChannelPiece e
ChannelCloud (Maybe RssCloud -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe RssCloud)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m (Maybe RssCloud)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe RssCloud)
rssCloud
          , (Int -> ChannelPiece e) -> Maybe Int -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> ChannelPiece e
forall e. Int -> ChannelPiece e
ChannelTtl (Maybe Int -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe Int)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Int -> ConduitT Event o m (Maybe Int)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"ttl" (ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event o m Text
-> (Text -> ConduitT Event o m Int) -> ConduitT Event o m Int
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitT Event o m Int
forall (m :: * -> *). MonadThrow m => Text -> m Int
asInt)
          , (RssImage -> ChannelPiece e)
-> Maybe RssImage -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssImage -> ChannelPiece e
forall e. RssImage -> ChannelPiece e
ChannelImage (Maybe RssImage -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe RssImage)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m (Maybe RssImage)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe RssImage)
rssImage
          , (Text -> ChannelPiece e) -> Maybe Text -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> ChannelPiece e
forall e. Text -> ChannelPiece e
ChannelRating (Maybe Text -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe Text)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NameMatcher Name
-> ConduitT Event o m Text -> ConduitT Event o m (Maybe Text)
forall (m :: * -> *) a o b.
MonadThrow m =>
NameMatcher a
-> ConduitT Event o m b -> ConduitT Event o m (Maybe b)
tagIgnoreAttrs NameMatcher Name
"rating" ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (RssTextInput -> ChannelPiece e)
-> Maybe RssTextInput -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap RssTextInput -> ChannelPiece e
forall e. RssTextInput -> ChannelPiece e
ChannelTextInput (Maybe RssTextInput -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe RssTextInput)
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m (Maybe RssTextInput)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe RssTextInput)
rssTextInput
          , (Set Hour -> ChannelPiece e)
-> Maybe (Set Hour) -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Set Hour -> ChannelPiece e
forall e. Set Hour -> ChannelPiece e
ChannelSkipHours (Maybe (Set Hour) -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe (Set Hour))
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m (Maybe (Set Hour))
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe (Set Hour))
rssSkipHours
          , (Set Day -> ChannelPiece e)
-> Maybe (Set Day) -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Set Day -> ChannelPiece e
forall e. Set Day -> ChannelPiece e
ChannelSkipDays (Maybe (Set Day) -> Maybe (ChannelPiece e))
-> ConduitT Event o m (Maybe (Set Day))
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m (Maybe (Set Day))
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe (Set Day))
rssSkipDays
          , (NonEmpty Event -> ChannelPiece e)
-> Maybe (NonEmpty Event) -> Maybe (ChannelPiece e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap NonEmpty Event -> ChannelPiece e
forall e. NonEmpty Event -> ChannelPiece e
ChannelOther (Maybe (NonEmpty Event) -> Maybe (ChannelPiece e))
-> ([Event] -> Maybe (NonEmpty Event))
-> [Event]
-> Maybe (ChannelPiece e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Event] -> Maybe (NonEmpty Event)
forall a. [a] -> Maybe (NonEmpty a)
nonEmpty ([Event] -> Maybe (ChannelPiece e))
-> ConduitT Event o m [Event]
-> ConduitT Event o m (Maybe (ChannelPiece e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ConduitT Event Event m (Maybe ()) -> ConduitT Event Event m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ConduitT Event Event m (Maybe ())
forall (m :: * -> *).
MonadThrow m =>
ConduitT Event Event m (Maybe ())
takeAnyTreeContent ConduitT Event Event m ()
-> ConduitT Event o m [Event] -> ConduitT Event o m [Event]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitT Event o m [Event]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
          ]
  attributes :: AttrParser Version
attributes = (Name -> AttrParser Text
requireAttr Name
"version" AttrParser Text
-> (Text -> AttrParser Version) -> AttrParser Version
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> AttrParser Version
forall (m :: * -> *). MonadThrow m => Text -> m Version
asVersion) AttrParser Version -> AttrParser () -> AttrParser Version
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* AttrParser ()
ignoreAttrs