{-# LANGUAGE FlexibleContexts      #-}
{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedLists       #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RankNTypes            #-}
{-# LANGUAGE StandaloneDeriving    #-}
{-# LANGUAGE TemplateHaskell       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
-- | Streaming parsers for the Atom 1.0 standard.
module Text.Atom.Conduit.Parse
  ( -- * Top-level
    atomFeed
    -- * Elements
  , atomEntry
  , atomContent
  , atomCategory
  , atomLink
  , atomGenerator
  , atomSource
    -- * Constructs
  , atomPerson
  , atomText
  ) where

-- {{{ Imports
import           Blaze.ByteString.Builder (toByteString)
import           Conduit
import           Control.Applicative      hiding (many)
import           Control.Exception.Safe   as Exception
import           Control.Monad
import           Control.Monad.Fix
import           Data.Maybe
import           Data.Monoid
import           Data.Text                as Text (Text, unpack)
import           Data.Time.Clock
import           Data.Time.LocalTime
import           Data.Time.RFC3339
import           Data.XML.Types           as XML
import           Lens.Micro
import           Lens.Micro.TH
import           Refined
import           Text.Atom.Types
import           Text.XML.Stream.Parse
import qualified Text.XML.Stream.Render   as Render
import qualified Text.XML.Unresolved      as Unresolved

import           URI.ByteString
-- }}}

-- {{{ Util
data AtomException = InvalidDate Text
                   | InvalidURI URIParseError Text
                   | MissingElement Text

deriving instance Eq AtomException
deriving instance Show AtomException

instance Exception AtomException where
  displayException :: AtomException -> String
displayException (InvalidDate Text
t)    = String
"Invalid date: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
unpack Text
t
  displayException (InvalidURI URIParseError
e Text
t)   = String
"Invalid URI reference: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> URIParseError -> String
forall b a. (Show a, IsString b) => a -> b
show URIParseError
e String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" in " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
unpack Text
t
  displayException (MissingElement Text
t) = String
"Missing element: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
unpack Text
t

asURIReference :: MonadThrow m => Text -> m AtomURI
asURIReference :: Text -> m AtomURI
asURIReference 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)
_)     -> AtomURI -> m AtomURI
forall (m :: * -> *) a. Monad m => a -> m a
return (AtomURI -> m AtomURI) -> AtomURI -> m AtomURI
forall a b. (a -> b) -> a -> b
$ URIRef Absolute -> AtomURI
forall a. URIRef a -> AtomURI
AtomURI URIRef Absolute
u
  (Either URIParseError (URIRef Absolute)
_, Right URIRef Relative
u)     -> AtomURI -> m AtomURI
forall (m :: * -> *) a. Monad m => a -> m a
return (AtomURI -> m AtomURI) -> AtomURI -> m AtomURI
forall a b. (a -> b) -> a -> b
$ URIRef Relative -> AtomURI
forall a. URIRef a -> AtomURI
AtomURI URIRef Relative
u
  (Left URIParseError
_, Left URIParseError
e) -> AtomException -> m AtomURI
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throw (AtomException -> m AtomURI) -> AtomException -> m AtomURI
forall a b. (a -> b) -> a -> b
$ URIParseError -> Text -> AtomException
InvalidURI URIParseError
e Text
t
  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
forall a b. ConvertUtf8 a b => a -> b
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
forall a b. ConvertUtf8 a b => a -> b
encodeUtf8

liftMaybe :: (MonadThrow m, Exception e) => e -> Maybe a -> m a
liftMaybe :: e -> Maybe a -> m a
liftMaybe e
e = m a -> (a -> m a) -> Maybe a -> m a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (e -> m a
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throw e
e) a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return

-- | 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
&& Name -> Maybe Text
nameNamespace Name
n Maybe Text -> Maybe Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"http://www.w3.org/2005/Atom")

-- | Tag which content is a date-time that follows RFC 3339 format.
tagDate :: MonadThrow m => Text -> ConduitM Event o m (Maybe UTCTime)
tagDate :: Text -> ConduitM Event o m (Maybe UTCTime)
tagDate Text
name = Text
-> ConduitM Event o m UTCTime -> ConduitM Event o m (Maybe UTCTime)
forall (m :: * -> *) o a.
MonadThrow m =>
Text -> ConduitM Event o m a -> ConduitM Event o m (Maybe a)
tagIgnoreAttrs' Text
name (ConduitM Event o m UTCTime -> ConduitM Event o m (Maybe UTCTime))
-> ConduitM 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
  ZonedTime -> UTCTime
zonedTimeToUTC (ZonedTime -> UTCTime)
-> ConduitT Event o m ZonedTime -> ConduitM Event o m UTCTime
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AtomException -> Maybe ZonedTime -> ConduitT Event o m ZonedTime
forall (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> Maybe a -> m a
liftMaybe (Text -> AtomException
InvalidDate Text
text) (Text -> Maybe ZonedTime
forall t. TextualMonoid t => t -> Maybe ZonedTime
parseTimeRFC3339 Text
text)

-- | Like 'tagName'' but ignores all attributes.
tagIgnoreAttrs' :: MonadThrow m => Text -> ConduitM Event o m a -> ConduitM Event o m (Maybe a)
tagIgnoreAttrs' :: Text -> ConduitM Event o m a -> ConduitM Event o m (Maybe a)
tagIgnoreAttrs' Text
name ConduitM Event o m a
handler = Text
-> AttrParser ()
-> (() -> ConduitM Event o m a)
-> ConduitM Event o m (Maybe a)
forall (m :: * -> *) a o b.
MonadThrow m =>
Text
-> AttrParser a
-> (a -> ConduitM Event o m b)
-> ConduitM Event o m (Maybe b)
tagName' Text
name AttrParser ()
ignoreAttrs ((() -> ConduitM Event o m a) -> ConduitM Event o m (Maybe a))
-> (() -> ConduitM Event o m a) -> ConduitM Event o m (Maybe a)
forall a b. (a -> b) -> a -> b
$ ConduitM Event o m a -> () -> ConduitM Event o m a
forall a b. a -> b -> a
const ConduitM Event o m a
handler

xhtmlContent :: MonadThrow m => ConduitM Event o m XML.Element
xhtmlContent :: ConduitM Event o m Element
xhtmlContent = String
-> ConduitT Event o m (Maybe Element) -> ConduitM Event o m Element
forall (m :: * -> *) a.
MonadThrow m =>
String -> m (Maybe a) -> m a
force String
"element" (ConduitT Event o m (Maybe Element) -> ConduitM Event o m Element)
-> ConduitT Event o m (Maybe Element) -> ConduitM Event o m Element
forall a b. (a -> b) -> a -> b
$ ConduitT Event Event m (Maybe ()) -> ConduitT Event Event m ()
forall (m :: * -> *) o a.
MonadThrow m =>
ConduitT Event o m (Maybe a) -> ConduitT Event o m ()
many_ ConduitT Event Event m (Maybe ())
forall (m :: * -> *).
MonadThrow m =>
ConduitT Event Event m (Maybe ())
takeAnyTreeContent ConduitT Event Event m ()
-> ConduitT Event o m (Maybe Element)
-> ConduitT Event o m (Maybe Element)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| (Event -> (Maybe PositionRange, Event))
-> ConduitT Event (Maybe PositionRange, Event) m ()
forall (m :: * -> *) a b. Monad m => (a -> b) -> ConduitT a b m ()
mapC (Maybe PositionRange
forall a. Maybe a
Nothing, ) ConduitT Event (Maybe PositionRange, Event) m ()
-> ConduitM (Maybe PositionRange, Event) o m (Maybe Element)
-> ConduitT Event o m (Maybe Element)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM (Maybe PositionRange, Event) o m (Maybe Element)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitT (Maybe PositionRange, Event) o m (Maybe Element)
Unresolved.elementFromEvents


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 ()

headRequiredC :: MonadThrow m => Text -> ConduitT a o m a
headRequiredC :: Text -> ConduitT a o m a
headRequiredC Text
e = AtomException -> Maybe a -> ConduitT a o m a
forall (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
e -> Maybe a -> m a
liftMaybe (Text -> AtomException
MissingElement Text
e) (Maybe a -> ConduitT a o m a)
-> ConduitT a o m (Maybe a) -> ConduitT a o m a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ConduitT a o m (Maybe a)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC

atomId :: MonadThrow m => ConduitM Event o m (Maybe Text)
atomId :: ConduitM Event o m (Maybe Text)
atomId = Text -> ConduitM Event o m Text -> ConduitM Event o m (Maybe Text)
forall (m :: * -> *) o a.
MonadThrow m =>
Text -> ConduitM Event o m a -> ConduitM Event o m (Maybe a)
tagIgnoreAttrs' Text
"id" ConduitM Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content

atomIcon, atomLogo :: MonadThrow m => ConduitM Event o m (Maybe AtomURI)
atomIcon :: ConduitM Event o m (Maybe AtomURI)
atomIcon = Text
-> ConduitM Event o m AtomURI -> ConduitM Event o m (Maybe AtomURI)
forall (m :: * -> *) o a.
MonadThrow m =>
Text -> ConduitM Event o m a -> ConduitM Event o m (Maybe a)
tagIgnoreAttrs' Text
"icon" (ConduitM Event o m AtomURI -> ConduitM Event o m (Maybe AtomURI))
-> ConduitM Event o m AtomURI -> ConduitM Event o m (Maybe AtomURI)
forall a b. (a -> b) -> a -> b
$ ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event o m Text
-> (Text -> ConduitM Event o m AtomURI)
-> ConduitM Event o m AtomURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitM Event o m AtomURI
forall (m :: * -> *). MonadThrow m => Text -> m AtomURI
asURIReference
 = Text
-> ConduitM Event o m AtomURI -> ConduitM Event o m (Maybe AtomURI)
forall (m :: * -> *) o a.
MonadThrow m =>
Text -> ConduitM Event o m a -> ConduitM Event o m (Maybe a)
tagIgnoreAttrs' Text
"logo" (ConduitM Event o m AtomURI -> ConduitM Event o m (Maybe AtomURI))
-> ConduitM Event o m AtomURI -> ConduitM Event o m (Maybe AtomURI)
forall a b. (a -> b) -> a -> b
$ ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event o m Text
-> (Text -> ConduitM Event o m AtomURI)
-> ConduitM Event o m AtomURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitM Event o m AtomURI
forall (m :: * -> *). MonadThrow m => Text -> m AtomURI
asURIReference
-- }}}


data PersonPiece = PersonName { PersonPiece -> Refined (Not Null) Text
__personName :: Refined (Not Null) Text }
                 | PersonEmail { PersonPiece -> Text
__personEmail :: Text }
                 | PersonUri { PersonPiece -> AtomURI
__personUri :: AtomURI }

makeLenses ''PersonPiece

-- | Parse an Atom person construct.
-- Example:
--
-- > <author>
-- >   <name>John Doe</name>
-- >   <email>JohnDoe@example.com</email>
-- >   <uri>http://example.com/~johndoe</uri>
-- > </author>
atomPerson :: MonadThrow m => Text -> ConduitM Event o m (Maybe AtomPerson)
atomPerson :: Text -> ConduitM Event o m (Maybe AtomPerson)
atomPerson Text
name = Text
-> ConduitM Event o m AtomPerson
-> ConduitM Event o m (Maybe AtomPerson)
forall (m :: * -> *) o a.
MonadThrow m =>
Text -> ConduitM Event o m a -> ConduitM Event o m (Maybe a)
tagIgnoreAttrs' Text
name (ConduitM Event o m AtomPerson
 -> ConduitM Event o m (Maybe AtomPerson))
-> ConduitM Event o m AtomPerson
-> ConduitM Event o m (Maybe AtomPerson)
forall a b. (a -> b) -> a -> b
$ (ConduitT Event PersonPiece m (Maybe PersonPiece)
-> ConduitT Event PersonPiece m ()
forall (m :: * -> *) b.
MonadThrow m =>
ConduitT Event b m (Maybe b) -> ConduitT Event b m ()
manyYield' ([ConduitT Event PersonPiece m (Maybe PersonPiece)]
-> ConduitT Event PersonPiece m (Maybe PersonPiece)
forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose [ConduitT Event PersonPiece m (Maybe PersonPiece)]
piece) ConduitT Event PersonPiece m ()
-> ConduitM PersonPiece o m AtomPerson
-> ConduitM Event o m AtomPerson
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM PersonPiece o m AtomPerson
forall o. ConduitT PersonPiece o m AtomPerson
parser) ConduitM Event o m AtomPerson
-> ConduitT Event o m [()] -> ConduitM Event o m AtomPerson
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 PersonPiece o m AtomPerson
parser = ZipConduit PersonPiece o m AtomPerson
-> ConduitT PersonPiece o m AtomPerson
forall i o (m :: * -> *) r. ZipConduit i o m r -> ConduitT i o m r
getZipConduit (ZipConduit PersonPiece o m AtomPerson
 -> ConduitT PersonPiece o m AtomPerson)
-> ZipConduit PersonPiece o m AtomPerson
-> ConduitT PersonPiece o m AtomPerson
forall a b. (a -> b) -> a -> b
$ Refined (Not Null) Text -> Text -> Maybe AtomURI -> AtomPerson
AtomPerson
    (Refined (Not Null) Text -> Text -> Maybe AtomURI -> AtomPerson)
-> ZipConduit PersonPiece o m (Refined (Not Null) Text)
-> ZipConduit PersonPiece o m (Text -> Maybe AtomURI -> AtomPerson)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT PersonPiece o m (Refined (Not Null) Text)
-> ZipConduit PersonPiece o m (Refined (Not Null) Text)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' PersonPiece (Refined (Not Null) Text)
-> ConduitT PersonPiece (Refined (Not Null) Text) m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' PersonPiece (Refined (Not Null) Text)
_personName ConduitT PersonPiece (Refined (Not Null) Text) m ()
-> ConduitM (Refined (Not Null) Text) o m (Refined (Not Null) Text)
-> ConduitT PersonPiece o m (Refined (Not Null) 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 (Refined (Not Null) Text) o m (Refined (Not Null) Text)
forall (m :: * -> *) a o. MonadThrow m => Text -> ConduitT a o m a
headRequiredC Text
"Missing or invalid <name> element")
    ZipConduit PersonPiece o m (Text -> Maybe AtomURI -> AtomPerson)
-> ZipConduit PersonPiece o m Text
-> ZipConduit PersonPiece o m (Maybe AtomURI -> AtomPerson)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT PersonPiece o m Text -> ZipConduit PersonPiece o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' PersonPiece Text -> ConduitT PersonPiece Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' PersonPiece Text
_personEmail ConduitT PersonPiece Text m ()
-> ConduitM Text o m Text -> ConduitT PersonPiece 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 PersonPiece o m (Maybe AtomURI -> AtomPerson)
-> ZipConduit PersonPiece o m (Maybe AtomURI)
-> ZipConduit PersonPiece o m AtomPerson
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT PersonPiece o m (Maybe AtomURI)
-> ZipConduit PersonPiece o m (Maybe AtomURI)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' PersonPiece AtomURI -> ConduitT PersonPiece AtomURI m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' PersonPiece AtomURI
_personUri ConduitT PersonPiece AtomURI m ()
-> ConduitM AtomURI o m (Maybe AtomURI)
-> ConduitT PersonPiece o m (Maybe AtomURI)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomURI o m (Maybe AtomURI)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
  piece :: [ConduitT Event PersonPiece m (Maybe PersonPiece)]
piece = [ (Refined (Not Null) Text -> PersonPiece)
-> Maybe (Refined (Not Null) Text) -> Maybe PersonPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Refined (Not Null) Text -> PersonPiece
PersonName (Maybe (Refined (Not Null) Text) -> Maybe PersonPiece)
-> ConduitT Event PersonPiece m (Maybe (Refined (Not Null) Text))
-> ConduitT Event PersonPiece m (Maybe PersonPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ConduitM Event PersonPiece m (Refined (Not Null) Text)
-> ConduitT Event PersonPiece m (Maybe (Refined (Not Null) Text))
forall (m :: * -> *) o a.
MonadThrow m =>
Text -> ConduitM Event o m a -> ConduitM Event o m (Maybe a)
tagIgnoreAttrs' Text
"name" (ConduitT Event PersonPiece m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event PersonPiece m Text
-> (Text -> ConduitM Event PersonPiece m (Refined (Not Null) Text))
-> ConduitM Event PersonPiece m (Refined (Not Null) Text)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitM Event PersonPiece m (Refined (Not Null) Text)
forall p x (m :: * -> *).
(Predicate p x, MonadThrow m) =>
x -> m (Refined p x)
refineThrow)
          , (Text -> PersonPiece) -> Maybe Text -> Maybe PersonPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> PersonPiece
PersonEmail (Maybe Text -> Maybe PersonPiece)
-> ConduitT Event PersonPiece m (Maybe Text)
-> ConduitT Event PersonPiece m (Maybe PersonPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ConduitT Event PersonPiece m Text
-> ConduitT Event PersonPiece m (Maybe Text)
forall (m :: * -> *) o a.
MonadThrow m =>
Text -> ConduitM Event o m a -> ConduitM Event o m (Maybe a)
tagIgnoreAttrs' Text
"email" ConduitT Event PersonPiece m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content
          , (AtomURI -> PersonPiece) -> Maybe AtomURI -> Maybe PersonPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomURI -> PersonPiece
PersonUri (Maybe AtomURI -> Maybe PersonPiece)
-> ConduitT Event PersonPiece m (Maybe AtomURI)
-> ConduitT Event PersonPiece m (Maybe PersonPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ConduitM Event PersonPiece m AtomURI
-> ConduitT Event PersonPiece m (Maybe AtomURI)
forall (m :: * -> *) o a.
MonadThrow m =>
Text -> ConduitM Event o m a -> ConduitM Event o m (Maybe a)
tagIgnoreAttrs' Text
"uri" (ConduitT Event PersonPiece m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content ConduitT Event PersonPiece m Text
-> (Text -> ConduitM Event PersonPiece m AtomURI)
-> ConduitM Event PersonPiece m AtomURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ConduitM Event PersonPiece m AtomURI
forall (m :: * -> *). MonadThrow m => Text -> m AtomURI
asURIReference)
          ]


-- | Parse an @atom:category@ element.
-- Example:
--
-- > <category term="sports"/>
atomCategory :: MonadThrow m => ConduitM Event o m (Maybe AtomCategory)
atomCategory :: ConduitM Event o m (Maybe AtomCategory)
atomCategory = Text
-> AttrParser (Text, Text, Text)
-> ((Text, Text, Text) -> ConduitM Event o m AtomCategory)
-> ConduitM Event o m (Maybe AtomCategory)
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, Text, Text)
categoryAttrs (((Text, Text, Text) -> ConduitM Event o m AtomCategory)
 -> ConduitM Event o m (Maybe AtomCategory))
-> ((Text, Text, Text) -> ConduitM Event o m AtomCategory)
-> ConduitM Event o m (Maybe AtomCategory)
forall a b. (a -> b) -> a -> b
$ \(Text
t, Text
s, Text
l) -> do
  Refined (Not Null) Text
term <- Text -> ConduitT Event o m (Refined (Not Null) Text)
forall p x (m :: * -> *).
(Predicate p x, MonadThrow m) =>
x -> m (Refined p x)
refineThrow Text
t
  AtomCategory -> ConduitM Event o m AtomCategory
forall (m :: * -> *) a. Monad m => a -> m a
return (AtomCategory -> ConduitM Event o m AtomCategory)
-> AtomCategory -> ConduitM Event o m AtomCategory
forall a b. (a -> b) -> a -> b
$ Refined (Not Null) Text -> Text -> Text -> AtomCategory
AtomCategory Refined (Not Null) Text
term Text
s Text
l
  where categoryAttrs :: AttrParser (Text, Text, Text)
categoryAttrs = (,,) (Text -> Text -> Text -> (Text, Text, Text))
-> AttrParser Text
-> AttrParser (Text -> Text -> (Text, Text, Text))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> AttrParser Text
requireAttr Name
"term"
                             AttrParser (Text -> Text -> (Text, Text, Text))
-> AttrParser Text -> AttrParser (Text -> (Text, Text, Text))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Name -> AttrParser Text
requireAttr Name
"scheme" AttrParser Text -> AttrParser Text -> AttrParser Text
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Text -> AttrParser Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
forall a. Monoid a => a
mempty)
                             AttrParser (Text -> (Text, Text, Text))
-> AttrParser Text -> AttrParser (Text, Text, Text)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Name -> AttrParser Text
requireAttr Name
"label" AttrParser Text -> AttrParser Text -> AttrParser Text
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Text -> AttrParser Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
forall a. Monoid a => a
mempty)
                             AttrParser (Text, Text, Text)
-> AttrParser () -> AttrParser (Text, Text, Text)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* AttrParser ()
ignoreAttrs

-- | Parse an @atom:content@ element.
atomContent :: MonadThrow m => ConduitM Event o m (Maybe AtomContent)
atomContent :: ConduitM Event o m (Maybe AtomContent)
atomContent = Text
-> AttrParser (Maybe Text, Maybe AtomURI)
-> ((Maybe Text, Maybe AtomURI) -> ConduitM Event o m AtomContent)
-> ConduitM Event o m (Maybe AtomContent)
forall (m :: * -> *) a o b.
MonadThrow m =>
Text
-> AttrParser a
-> (a -> ConduitM Event o m b)
-> ConduitM Event o m (Maybe b)
tagName' Text
"content" AttrParser (Maybe Text, Maybe AtomURI)
contentAttrs (Maybe Text, Maybe AtomURI) -> ConduitM Event o m AtomContent
forall (m :: * -> *) o.
MonadThrow m =>
(Maybe Text, Maybe AtomURI) -> ConduitT Event o m AtomContent
handler where
  contentAttrs :: AttrParser (Maybe Text, Maybe AtomURI)
contentAttrs = (,) (Maybe Text -> Maybe AtomURI -> (Maybe Text, Maybe AtomURI))
-> AttrParser (Maybe Text)
-> AttrParser (Maybe AtomURI -> (Maybe Text, Maybe AtomURI))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AttrParser Text -> AttrParser (Maybe Text)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Name -> AttrParser Text
requireAttr Name
"type") AttrParser (Maybe AtomURI -> (Maybe Text, Maybe AtomURI))
-> AttrParser (Maybe AtomURI)
-> AttrParser (Maybe Text, Maybe AtomURI)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> AttrParser AtomURI -> AttrParser (Maybe AtomURI)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Name -> AttrParser Text
requireAttr Name
"src" AttrParser Text
-> (Text -> AttrParser AtomURI) -> AttrParser AtomURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> AttrParser AtomURI
forall (m :: * -> *). MonadThrow m => Text -> m AtomURI
asURIReference) AttrParser (Maybe Text, Maybe AtomURI)
-> AttrParser () -> AttrParser (Maybe Text, Maybe AtomURI)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* AttrParser ()
ignoreAttrs
  handler :: (Maybe Text, Maybe AtomURI) -> ConduitT Event o m AtomContent
handler (Just Text
"xhtml", Maybe AtomURI
_) = Element -> AtomContent
AtomContentInlineXHTML (Element -> AtomContent)
-> ConduitT Event o m Element -> ConduitT Event o m AtomContent
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m Element
forall (m :: * -> *) o. MonadThrow m => ConduitM Event o m Element
xhtmlContent
  handler (Maybe Text
ctype, Just AtomURI
uri) = AtomContent -> ConduitT Event o m AtomContent
forall (m :: * -> *) a. Monad m => a -> m a
return (AtomContent -> ConduitT Event o m AtomContent)
-> AtomContent -> ConduitT Event o m AtomContent
forall a b. (a -> b) -> a -> b
$ Text -> AtomURI -> AtomContent
AtomContentOutOfLine (Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
forall a. Monoid a => a
mempty Maybe Text
ctype) AtomURI
uri
  handler (Just Text
"html", Maybe AtomURI
_)  = TextType -> Text -> AtomContent
AtomContentInlineText TextType
TypeHTML (Text -> AtomContent)
-> ConduitT Event o m Text -> ConduitT Event o m AtomContent
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
  handler (Maybe Text
Nothing, Maybe AtomURI
_)      = TextType -> Text -> AtomContent
AtomContentInlineText TextType
TypeText (Text -> AtomContent)
-> ConduitT Event o m Text -> ConduitT Event o m AtomContent
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
  handler (Just Text
ctype, Maybe AtomURI
_)   = Text -> Text -> AtomContent
AtomContentInlineOther Text
ctype (Text -> AtomContent)
-> ConduitT Event o m Text -> ConduitT Event o m AtomContent
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 @atom:link@ element.
-- Examples:
--
-- > <link rel="self" href="/feed" />
--
-- > <link rel="alternate" href="/blog/1234"/>
atomLink :: MonadThrow m => ConduitM Event o m (Maybe AtomLink)
atomLink :: ConduitM Event o m (Maybe AtomLink)
atomLink = Text
-> AttrParser (AtomURI, Text, Text, Text, Text, Text)
-> ((AtomURI, Text, Text, Text, Text, Text)
    -> ConduitM Event o m AtomLink)
-> ConduitM Event o m (Maybe AtomLink)
forall (m :: * -> *) a o b.
MonadThrow m =>
Text
-> AttrParser a
-> (a -> ConduitM Event o m b)
-> ConduitM Event o m (Maybe b)
tagName' Text
"link" AttrParser (AtomURI, Text, Text, Text, Text, Text)
linkAttrs (((AtomURI, Text, Text, Text, Text, Text)
  -> ConduitM Event o m AtomLink)
 -> ConduitM Event o m (Maybe AtomLink))
-> ((AtomURI, Text, Text, Text, Text, Text)
    -> ConduitM Event o m AtomLink)
-> ConduitM Event o m (Maybe AtomLink)
forall a b. (a -> b) -> a -> b
$ \(AtomURI
href, Text
rel, Text
ltype, Text
lang, Text
title, Text
length') ->
  AtomLink -> ConduitM Event o m AtomLink
forall (m :: * -> *) a. Monad m => a -> m a
return (AtomLink -> ConduitM Event o m AtomLink)
-> AtomLink -> ConduitM Event o m AtomLink
forall a b. (a -> b) -> a -> b
$ AtomURI -> Text -> Text -> Text -> Text -> Text -> AtomLink
AtomLink AtomURI
href Text
rel Text
ltype Text
lang Text
title Text
length'
  where linkAttrs :: AttrParser (AtomURI, Text, Text, Text, Text, Text)
linkAttrs = (,,,,,) (AtomURI
 -> Text
 -> Text
 -> Text
 -> Text
 -> Text
 -> (AtomURI, Text, Text, Text, Text, Text))
-> AttrParser AtomURI
-> AttrParser
     (Text
      -> Text
      -> Text
      -> Text
      -> Text
      -> (AtomURI, Text, Text, Text, Text, Text))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Name -> AttrParser Text
requireAttr Name
"href" AttrParser Text
-> (Text -> AttrParser AtomURI) -> AttrParser AtomURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> AttrParser AtomURI
forall (m :: * -> *). MonadThrow m => Text -> m AtomURI
asURIReference)
                            AttrParser
  (Text
   -> Text
   -> Text
   -> Text
   -> Text
   -> (AtomURI, Text, Text, Text, Text, Text))
-> AttrParser Text
-> AttrParser
     (Text
      -> Text -> Text -> Text -> (AtomURI, Text, Text, Text, Text, Text))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Name -> AttrParser Text
requireAttr Name
"rel" AttrParser Text -> AttrParser Text -> AttrParser Text
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Text -> AttrParser Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
forall a. Monoid a => a
mempty)
                            AttrParser
  (Text
   -> Text -> Text -> Text -> (AtomURI, Text, Text, Text, Text, Text))
-> AttrParser Text
-> AttrParser
     (Text -> Text -> Text -> (AtomURI, Text, Text, Text, Text, Text))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Name -> AttrParser Text
requireAttr Name
"type" AttrParser Text -> AttrParser Text -> AttrParser Text
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Text -> AttrParser Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
forall a. Monoid a => a
mempty)
                            AttrParser
  (Text -> Text -> Text -> (AtomURI, Text, Text, Text, Text, Text))
-> AttrParser Text
-> AttrParser
     (Text -> Text -> (AtomURI, Text, Text, Text, Text, Text))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Name -> AttrParser Text
requireAttr Name
"hreflang" AttrParser Text -> AttrParser Text -> AttrParser Text
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Text -> AttrParser Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
forall a. Monoid a => a
mempty)
                            AttrParser
  (Text -> Text -> (AtomURI, Text, Text, Text, Text, Text))
-> AttrParser Text
-> AttrParser (Text -> (AtomURI, Text, Text, Text, Text, Text))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Name -> AttrParser Text
requireAttr Name
"title" AttrParser Text -> AttrParser Text -> AttrParser Text
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Text -> AttrParser Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
forall a. Monoid a => a
mempty)
                            AttrParser (Text -> (AtomURI, Text, Text, Text, Text, Text))
-> AttrParser Text
-> AttrParser (AtomURI, Text, Text, Text, Text, Text)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Name -> AttrParser Text
requireAttr Name
"length" AttrParser Text -> AttrParser Text -> AttrParser Text
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Text -> AttrParser Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
forall a. Monoid a => a
mempty)
                            AttrParser (AtomURI, Text, Text, Text, Text, Text)
-> AttrParser ()
-> AttrParser (AtomURI, Text, Text, Text, Text, Text)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* AttrParser ()
ignoreAttrs

-- | Parse an Atom text construct.
-- Examples:
--
-- > <title type="text">AT&amp;T bought by SBC!</title>
--
-- > <title type="html">
-- >   AT&amp;amp;T bought &lt;b&gt;by SBC&lt;/b&gt;!
-- > </title>
--
-- > <title type="xhtml">
-- >   <div xmlns="http://www.w3.org/1999/xhtml">
-- >     AT&amp;T bought <b>by SBC</b>!
-- >   </div>
-- > </title>
atomText :: MonadThrow m => Text -> ConduitM Event o m (Maybe AtomText)
atomText :: Text -> ConduitM Event o m (Maybe AtomText)
atomText Text
name = Text
-> AttrParser (Maybe Text)
-> (Maybe Text -> ConduitM Event o m AtomText)
-> ConduitM Event o m (Maybe AtomText)
forall (m :: * -> *) a o b.
MonadThrow m =>
Text
-> AttrParser a
-> (a -> ConduitM Event o m b)
-> ConduitM Event o m (Maybe b)
tagName' Text
name (AttrParser Text -> AttrParser (Maybe Text)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Name -> AttrParser Text
requireAttr Name
"type") 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 AtomText
forall a (m :: * -> *) o.
(Eq a, IsString a, MonadThrow m) =>
Maybe a -> ConduitT Event o m AtomText
handler
  where handler :: Maybe a -> ConduitT Event o m AtomText
handler (Just a
"xhtml") = Element -> AtomText
AtomXHTMLText (Element -> AtomText)
-> ConduitT Event o m Element -> ConduitT Event o m AtomText
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event o m Element
forall (m :: * -> *) o. MonadThrow m => ConduitM Event o m Element
xhtmlContent
        handler (Just a
"html")  = TextType -> Text -> AtomText
AtomPlainText TextType
TypeHTML (Text -> AtomText)
-> ConduitT Event o m Text -> ConduitT Event o m AtomText
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
        handler Maybe a
_              = TextType -> Text -> AtomText
AtomPlainText TextType
TypeText (Text -> AtomText)
-> ConduitT Event o m Text -> ConduitT Event o m AtomText
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 @atom:generator@ element.
-- Example:
--
-- > <generator uri="/myblog.php" version="1.0">
-- >   Example Toolkit
-- > </generator>
atomGenerator :: MonadThrow m => ConduitM Event o m (Maybe AtomGenerator)
atomGenerator :: ConduitM Event o m (Maybe AtomGenerator)
atomGenerator = Text
-> AttrParser (Maybe AtomURI, Text)
-> ((Maybe AtomURI, Text) -> ConduitM Event o m AtomGenerator)
-> ConduitM Event o m (Maybe AtomGenerator)
forall (m :: * -> *) a o b.
MonadThrow m =>
Text
-> AttrParser a
-> (a -> ConduitM Event o m b)
-> ConduitM Event o m (Maybe b)
tagName' Text
"generator" AttrParser (Maybe AtomURI, Text)
generatorAttrs (((Maybe AtomURI, Text) -> ConduitM Event o m AtomGenerator)
 -> ConduitM Event o m (Maybe AtomGenerator))
-> ((Maybe AtomURI, Text) -> ConduitM Event o m AtomGenerator)
-> ConduitM Event o m (Maybe AtomGenerator)
forall a b. (a -> b) -> a -> b
$ \(Maybe AtomURI
uri, Text
version) -> Maybe AtomURI -> Text -> Refined (Not Null) Text -> AtomGenerator
AtomGenerator Maybe AtomURI
uri Text
version (Refined (Not Null) Text -> AtomGenerator)
-> ConduitT Event o m (Refined (Not Null) Text)
-> ConduitM Event o m AtomGenerator
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Text -> ConduitT Event o m (Refined (Not Null) Text)
forall p x (m :: * -> *).
(Predicate p x, MonadThrow m) =>
x -> m (Refined p x)
refineThrow (Text -> ConduitT Event o m (Refined (Not Null) Text))
-> ConduitT Event o m Text
-> ConduitT Event o m (Refined (Not Null) Text)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ConduitT Event o m Text
forall (m :: * -> *) o. MonadThrow m => ConduitT Event o m Text
content)
  where generatorAttrs :: AttrParser (Maybe AtomURI, Text)
generatorAttrs = (,) (Maybe AtomURI -> Text -> (Maybe AtomURI, Text))
-> AttrParser (Maybe AtomURI)
-> AttrParser (Text -> (Maybe AtomURI, Text))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AttrParser AtomURI -> AttrParser (Maybe AtomURI)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Name -> AttrParser Text
requireAttr Name
"uri" AttrParser Text
-> (Text -> AttrParser AtomURI) -> AttrParser AtomURI
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> AttrParser AtomURI
forall (m :: * -> *). MonadThrow m => Text -> m AtomURI
asURIReference) AttrParser (Text -> (Maybe AtomURI, Text))
-> AttrParser Text -> AttrParser (Maybe AtomURI, Text)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Name -> AttrParser Text
requireAttr Name
"version" AttrParser Text -> AttrParser Text -> AttrParser Text
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Text -> AttrParser Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
forall a. Monoid a => a
mempty) AttrParser (Maybe AtomURI, Text)
-> AttrParser () -> AttrParser (Maybe AtomURI, Text)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* AttrParser ()
ignoreAttrs


data SourcePiece = SourceAuthor { SourcePiece -> AtomPerson
__sourceAuthor :: AtomPerson }
                 | SourceCategory { SourcePiece -> AtomCategory
__sourceCategory :: AtomCategory }
                 | SourceContributor { SourcePiece -> AtomPerson
__sourceContributor :: AtomPerson }
                 | SourceGenerator { SourcePiece -> AtomGenerator
__sourceGenerator :: AtomGenerator }
                 | SourceIcon { SourcePiece -> AtomURI
__sourceIcon :: AtomURI }
                 | SourceId { SourcePiece -> Text
__sourceId :: Text }
                 | SourceLink { SourcePiece -> AtomLink
__sourceLink :: AtomLink }
                 |  {  :: AtomURI }
                 | SourceRights { SourcePiece -> AtomText
__sourceRights :: AtomText }
                 | SourceSubtitle { SourcePiece -> AtomText
__sourceSubtitle :: AtomText }
                 | SourceTitle { SourcePiece -> AtomText
__sourceTitle :: AtomText }
                 | SourceUpdated { SourcePiece -> UTCTime
__sourceUpdated :: UTCTime }



-- | Parse an @atom:source@ element.
-- Example:
--
-- > <source>
-- >   <id>http://example.org/</id>
-- >   <title>Fourty-Two</title>
-- >   <updated>2003-12-13T18:30:02Z</updated>
-- >   <rights>© 2005 Example, Inc.</rights>
-- > </source>
atomSource :: MonadThrow m => ConduitM Event o m (Maybe AtomSource)
atomSource :: ConduitM Event o m (Maybe AtomSource)
atomSource = Text
-> ConduitM Event o m AtomSource
-> ConduitM Event o m (Maybe AtomSource)
forall (m :: * -> *) o a.
MonadThrow m =>
Text -> ConduitM Event o m a -> ConduitM Event o m (Maybe a)
tagIgnoreAttrs' Text
"source" (ConduitM Event o m AtomSource
 -> ConduitM Event o m (Maybe AtomSource))
-> ConduitM Event o m AtomSource
-> ConduitM Event o m (Maybe AtomSource)
forall a b. (a -> b) -> a -> b
$ ConduitT Event SourcePiece m (Maybe SourcePiece)
-> ConduitT Event SourcePiece m ()
forall (m :: * -> *) b.
MonadThrow m =>
ConduitT Event b m (Maybe b) -> ConduitT Event b m ()
manyYield' ([ConduitT Event SourcePiece m (Maybe SourcePiece)]
-> ConduitT Event SourcePiece m (Maybe SourcePiece)
forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose [ConduitT Event SourcePiece m (Maybe SourcePiece)]
piece) ConduitT Event SourcePiece m ()
-> ConduitM SourcePiece o m AtomSource
-> ConduitM Event o m AtomSource
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM SourcePiece o m AtomSource
forall o. ConduitT SourcePiece o m AtomSource
zipConduit where
  zipConduit :: ConduitT SourcePiece o m AtomSource
zipConduit = ZipConduit SourcePiece o m AtomSource
-> ConduitT SourcePiece o m AtomSource
forall i o (m :: * -> *) r. ZipConduit i o m r -> ConduitT i o m r
getZipConduit (ZipConduit SourcePiece o m AtomSource
 -> ConduitT SourcePiece o m AtomSource)
-> ZipConduit SourcePiece o m AtomSource
-> ConduitT SourcePiece o m AtomSource
forall a b. (a -> b) -> a -> b
$ [AtomPerson]
-> [AtomCategory]
-> [AtomPerson]
-> Maybe AtomGenerator
-> Maybe AtomURI
-> Text
-> [AtomLink]
-> Maybe AtomURI
-> Maybe AtomText
-> Maybe AtomText
-> Maybe AtomText
-> Maybe UTCTime
-> AtomSource
AtomSource
    ([AtomPerson]
 -> [AtomCategory]
 -> [AtomPerson]
 -> Maybe AtomGenerator
 -> Maybe AtomURI
 -> Text
 -> [AtomLink]
 -> Maybe AtomURI
 -> Maybe AtomText
 -> Maybe AtomText
 -> Maybe AtomText
 -> Maybe UTCTime
 -> AtomSource)
-> ZipConduit SourcePiece o m [AtomPerson]
-> ZipConduit
     SourcePiece
     o
     m
     ([AtomCategory]
      -> [AtomPerson]
      -> Maybe AtomGenerator
      -> Maybe AtomURI
      -> Text
      -> [AtomLink]
      -> Maybe AtomURI
      -> Maybe AtomText
      -> Maybe AtomText
      -> Maybe AtomText
      -> Maybe UTCTime
      -> AtomSource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT SourcePiece o m [AtomPerson]
-> ZipConduit SourcePiece o m [AtomPerson]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' SourcePiece AtomPerson
-> ConduitT SourcePiece AtomPerson m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' SourcePiece AtomPerson
_sourceAuthor ConduitT SourcePiece AtomPerson m ()
-> ConduitM AtomPerson o m [AtomPerson]
-> ConduitT SourcePiece o m [AtomPerson]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomPerson o m [AtomPerson]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  SourcePiece
  o
  m
  ([AtomCategory]
   -> [AtomPerson]
   -> Maybe AtomGenerator
   -> Maybe AtomURI
   -> Text
   -> [AtomLink]
   -> Maybe AtomURI
   -> Maybe AtomText
   -> Maybe AtomText
   -> Maybe AtomText
   -> Maybe UTCTime
   -> AtomSource)
-> ZipConduit SourcePiece o m [AtomCategory]
-> ZipConduit
     SourcePiece
     o
     m
     ([AtomPerson]
      -> Maybe AtomGenerator
      -> Maybe AtomURI
      -> Text
      -> [AtomLink]
      -> Maybe AtomURI
      -> Maybe AtomText
      -> Maybe AtomText
      -> Maybe AtomText
      -> Maybe UTCTime
      -> AtomSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT SourcePiece o m [AtomCategory]
-> ZipConduit SourcePiece o m [AtomCategory]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' SourcePiece AtomCategory
-> ConduitT SourcePiece AtomCategory m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' SourcePiece AtomCategory
_sourceCategory ConduitT SourcePiece AtomCategory m ()
-> ConduitM AtomCategory o m [AtomCategory]
-> ConduitT SourcePiece o m [AtomCategory]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomCategory o m [AtomCategory]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  SourcePiece
  o
  m
  ([AtomPerson]
   -> Maybe AtomGenerator
   -> Maybe AtomURI
   -> Text
   -> [AtomLink]
   -> Maybe AtomURI
   -> Maybe AtomText
   -> Maybe AtomText
   -> Maybe AtomText
   -> Maybe UTCTime
   -> AtomSource)
-> ZipConduit SourcePiece o m [AtomPerson]
-> ZipConduit
     SourcePiece
     o
     m
     (Maybe AtomGenerator
      -> Maybe AtomURI
      -> Text
      -> [AtomLink]
      -> Maybe AtomURI
      -> Maybe AtomText
      -> Maybe AtomText
      -> Maybe AtomText
      -> Maybe UTCTime
      -> AtomSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT SourcePiece o m [AtomPerson]
-> ZipConduit SourcePiece o m [AtomPerson]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' SourcePiece AtomPerson
-> ConduitT SourcePiece AtomPerson m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' SourcePiece AtomPerson
_sourceContributor ConduitT SourcePiece AtomPerson m ()
-> ConduitM AtomPerson o m [AtomPerson]
-> ConduitT SourcePiece o m [AtomPerson]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomPerson o m [AtomPerson]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  SourcePiece
  o
  m
  (Maybe AtomGenerator
   -> Maybe AtomURI
   -> Text
   -> [AtomLink]
   -> Maybe AtomURI
   -> Maybe AtomText
   -> Maybe AtomText
   -> Maybe AtomText
   -> Maybe UTCTime
   -> AtomSource)
-> ZipConduit SourcePiece o m (Maybe AtomGenerator)
-> ZipConduit
     SourcePiece
     o
     m
     (Maybe AtomURI
      -> Text
      -> [AtomLink]
      -> Maybe AtomURI
      -> Maybe AtomText
      -> Maybe AtomText
      -> Maybe AtomText
      -> Maybe UTCTime
      -> AtomSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT SourcePiece o m (Maybe AtomGenerator)
-> ZipConduit SourcePiece o m (Maybe AtomGenerator)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' SourcePiece AtomGenerator
-> ConduitT SourcePiece AtomGenerator m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' SourcePiece AtomGenerator
_sourceGenerator ConduitT SourcePiece AtomGenerator m ()
-> ConduitM AtomGenerator o m (Maybe AtomGenerator)
-> ConduitT SourcePiece o m (Maybe AtomGenerator)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomGenerator o m (Maybe AtomGenerator)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  SourcePiece
  o
  m
  (Maybe AtomURI
   -> Text
   -> [AtomLink]
   -> Maybe AtomURI
   -> Maybe AtomText
   -> Maybe AtomText
   -> Maybe AtomText
   -> Maybe UTCTime
   -> AtomSource)
-> ZipConduit SourcePiece o m (Maybe AtomURI)
-> ZipConduit
     SourcePiece
     o
     m
     (Text
      -> [AtomLink]
      -> Maybe AtomURI
      -> Maybe AtomText
      -> Maybe AtomText
      -> Maybe AtomText
      -> Maybe UTCTime
      -> AtomSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT SourcePiece o m (Maybe AtomURI)
-> ZipConduit SourcePiece o m (Maybe AtomURI)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' SourcePiece AtomURI -> ConduitT SourcePiece AtomURI m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' SourcePiece AtomURI
_sourceIcon ConduitT SourcePiece AtomURI m ()
-> ConduitM AtomURI o m (Maybe AtomURI)
-> ConduitT SourcePiece o m (Maybe AtomURI)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomURI o m (Maybe AtomURI)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  SourcePiece
  o
  m
  (Text
   -> [AtomLink]
   -> Maybe AtomURI
   -> Maybe AtomText
   -> Maybe AtomText
   -> Maybe AtomText
   -> Maybe UTCTime
   -> AtomSource)
-> ZipConduit SourcePiece o m Text
-> ZipConduit
     SourcePiece
     o
     m
     ([AtomLink]
      -> Maybe AtomURI
      -> Maybe AtomText
      -> Maybe AtomText
      -> Maybe AtomText
      -> Maybe UTCTime
      -> AtomSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT SourcePiece o m Text -> ZipConduit SourcePiece o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' SourcePiece Text -> ConduitT SourcePiece Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' SourcePiece Text
_sourceId ConduitT SourcePiece Text m ()
-> ConduitM Text o m Text -> ConduitT SourcePiece 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
  SourcePiece
  o
  m
  ([AtomLink]
   -> Maybe AtomURI
   -> Maybe AtomText
   -> Maybe AtomText
   -> Maybe AtomText
   -> Maybe UTCTime
   -> AtomSource)
-> ZipConduit SourcePiece o m [AtomLink]
-> ZipConduit
     SourcePiece
     o
     m
     (Maybe AtomURI
      -> Maybe AtomText
      -> Maybe AtomText
      -> Maybe AtomText
      -> Maybe UTCTime
      -> AtomSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT SourcePiece o m [AtomLink]
-> ZipConduit SourcePiece o m [AtomLink]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' SourcePiece AtomLink
-> ConduitT SourcePiece AtomLink m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' SourcePiece AtomLink
_sourceLink ConduitT SourcePiece AtomLink m ()
-> ConduitM AtomLink o m [AtomLink]
-> ConduitT SourcePiece o m [AtomLink]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomLink o m [AtomLink]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  SourcePiece
  o
  m
  (Maybe AtomURI
   -> Maybe AtomText
   -> Maybe AtomText
   -> Maybe AtomText
   -> Maybe UTCTime
   -> AtomSource)
-> ZipConduit SourcePiece o m (Maybe AtomURI)
-> ZipConduit
     SourcePiece
     o
     m
     (Maybe AtomText
      -> Maybe AtomText -> Maybe AtomText -> Maybe UTCTime -> AtomSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT SourcePiece o m (Maybe AtomURI)
-> ZipConduit SourcePiece o m (Maybe AtomURI)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' SourcePiece AtomURI -> ConduitT SourcePiece AtomURI m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' SourcePiece AtomURI
_sourceLogo ConduitT SourcePiece AtomURI m ()
-> ConduitM AtomURI o m (Maybe AtomURI)
-> ConduitT SourcePiece o m (Maybe AtomURI)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomURI o m (Maybe AtomURI)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  SourcePiece
  o
  m
  (Maybe AtomText
   -> Maybe AtomText -> Maybe AtomText -> Maybe UTCTime -> AtomSource)
-> ZipConduit SourcePiece o m (Maybe AtomText)
-> ZipConduit
     SourcePiece
     o
     m
     (Maybe AtomText -> Maybe AtomText -> Maybe UTCTime -> AtomSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT SourcePiece o m (Maybe AtomText)
-> ZipConduit SourcePiece o m (Maybe AtomText)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' SourcePiece AtomText
-> ConduitT SourcePiece AtomText m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' SourcePiece AtomText
_sourceRights ConduitT SourcePiece AtomText m ()
-> ConduitM AtomText o m (Maybe AtomText)
-> ConduitT SourcePiece o m (Maybe AtomText)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomText o m (Maybe AtomText)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  SourcePiece
  o
  m
  (Maybe AtomText -> Maybe AtomText -> Maybe UTCTime -> AtomSource)
-> ZipConduit SourcePiece o m (Maybe AtomText)
-> ZipConduit
     SourcePiece o m (Maybe AtomText -> Maybe UTCTime -> AtomSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT SourcePiece o m (Maybe AtomText)
-> ZipConduit SourcePiece o m (Maybe AtomText)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' SourcePiece AtomText
-> ConduitT SourcePiece AtomText m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' SourcePiece AtomText
_sourceSubtitle ConduitT SourcePiece AtomText m ()
-> ConduitM AtomText o m (Maybe AtomText)
-> ConduitT SourcePiece o m (Maybe AtomText)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomText o m (Maybe AtomText)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  SourcePiece o m (Maybe AtomText -> Maybe UTCTime -> AtomSource)
-> ZipConduit SourcePiece o m (Maybe AtomText)
-> ZipConduit SourcePiece o m (Maybe UTCTime -> AtomSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT SourcePiece o m (Maybe AtomText)
-> ZipConduit SourcePiece o m (Maybe AtomText)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' SourcePiece AtomText
-> ConduitT SourcePiece AtomText m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' SourcePiece AtomText
_sourceTitle ConduitT SourcePiece AtomText m ()
-> ConduitM AtomText o m (Maybe AtomText)
-> ConduitT SourcePiece o m (Maybe AtomText)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomText o m (Maybe AtomText)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit SourcePiece o m (Maybe UTCTime -> AtomSource)
-> ZipConduit SourcePiece o m (Maybe UTCTime)
-> ZipConduit SourcePiece o m AtomSource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT SourcePiece o m (Maybe UTCTime)
-> ZipConduit SourcePiece o m (Maybe UTCTime)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' SourcePiece UTCTime -> ConduitT SourcePiece UTCTime m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' SourcePiece UTCTime
_sourceUpdated ConduitT SourcePiece UTCTime m ()
-> ConduitM UTCTime o m (Maybe UTCTime)
-> ConduitT SourcePiece 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)
  piece :: [ConduitT Event SourcePiece m (Maybe SourcePiece)]
piece = [ (AtomPerson -> SourcePiece)
-> Maybe AtomPerson -> Maybe SourcePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomPerson -> SourcePiece
SourceAuthor (Maybe AtomPerson -> Maybe SourcePiece)
-> ConduitT Event SourcePiece m (Maybe AtomPerson)
-> ConduitT Event SourcePiece m (Maybe SourcePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event SourcePiece m (Maybe AtomPerson)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe AtomPerson)
atomPerson Text
"author"
          , (AtomCategory -> SourcePiece)
-> Maybe AtomCategory -> Maybe SourcePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomCategory -> SourcePiece
SourceCategory (Maybe AtomCategory -> Maybe SourcePiece)
-> ConduitT Event SourcePiece m (Maybe AtomCategory)
-> ConduitT Event SourcePiece m (Maybe SourcePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event SourcePiece m (Maybe AtomCategory)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomCategory)
atomCategory
          , (AtomPerson -> SourcePiece)
-> Maybe AtomPerson -> Maybe SourcePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomPerson -> SourcePiece
SourceContributor (Maybe AtomPerson -> Maybe SourcePiece)
-> ConduitT Event SourcePiece m (Maybe AtomPerson)
-> ConduitT Event SourcePiece m (Maybe SourcePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event SourcePiece m (Maybe AtomPerson)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe AtomPerson)
atomPerson Text
"contributor"
          , (AtomGenerator -> SourcePiece)
-> Maybe AtomGenerator -> Maybe SourcePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomGenerator -> SourcePiece
SourceGenerator (Maybe AtomGenerator -> Maybe SourcePiece)
-> ConduitT Event SourcePiece m (Maybe AtomGenerator)
-> ConduitT Event SourcePiece m (Maybe SourcePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event SourcePiece m (Maybe AtomGenerator)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomGenerator)
atomGenerator
          , (AtomURI -> SourcePiece) -> Maybe AtomURI -> Maybe SourcePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomURI -> SourcePiece
SourceIcon (Maybe AtomURI -> Maybe SourcePiece)
-> ConduitT Event SourcePiece m (Maybe AtomURI)
-> ConduitT Event SourcePiece m (Maybe SourcePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event SourcePiece m (Maybe AtomURI)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomURI)
atomIcon
          , (Text -> SourcePiece) -> Maybe Text -> Maybe SourcePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> SourcePiece
SourceId (Maybe Text -> Maybe SourcePiece)
-> ConduitT Event SourcePiece m (Maybe Text)
-> ConduitT Event SourcePiece m (Maybe SourcePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event SourcePiece m (Maybe Text)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe Text)
atomId
          , (AtomLink -> SourcePiece) -> Maybe AtomLink -> Maybe SourcePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomLink -> SourcePiece
SourceLink (Maybe AtomLink -> Maybe SourcePiece)
-> ConduitT Event SourcePiece m (Maybe AtomLink)
-> ConduitT Event SourcePiece m (Maybe SourcePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event SourcePiece m (Maybe AtomLink)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomLink)
atomLink
          , (AtomURI -> SourcePiece) -> Maybe AtomURI -> Maybe SourcePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomURI -> SourcePiece
SourceLogo (Maybe AtomURI -> Maybe SourcePiece)
-> ConduitT Event SourcePiece m (Maybe AtomURI)
-> ConduitT Event SourcePiece m (Maybe SourcePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event SourcePiece m (Maybe AtomURI)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomURI)
atomLogo
          , (AtomText -> SourcePiece) -> Maybe AtomText -> Maybe SourcePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomText -> SourcePiece
SourceRights (Maybe AtomText -> Maybe SourcePiece)
-> ConduitT Event SourcePiece m (Maybe AtomText)
-> ConduitT Event SourcePiece m (Maybe SourcePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event SourcePiece m (Maybe AtomText)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe AtomText)
atomText Text
"rights"
          , (AtomText -> SourcePiece) -> Maybe AtomText -> Maybe SourcePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomText -> SourcePiece
SourceSubtitle (Maybe AtomText -> Maybe SourcePiece)
-> ConduitT Event SourcePiece m (Maybe AtomText)
-> ConduitT Event SourcePiece m (Maybe SourcePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event SourcePiece m (Maybe AtomText)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe AtomText)
atomText Text
"subtitle"
          , (AtomText -> SourcePiece) -> Maybe AtomText -> Maybe SourcePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomText -> SourcePiece
SourceTitle (Maybe AtomText -> Maybe SourcePiece)
-> ConduitT Event SourcePiece m (Maybe AtomText)
-> ConduitT Event SourcePiece m (Maybe SourcePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event SourcePiece m (Maybe AtomText)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe AtomText)
atomText Text
"title"
          , (UTCTime -> SourcePiece) -> Maybe UTCTime -> Maybe SourcePiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap UTCTime -> SourcePiece
SourceUpdated (Maybe UTCTime -> Maybe SourcePiece)
-> ConduitT Event SourcePiece m (Maybe UTCTime)
-> ConduitT Event SourcePiece m (Maybe SourcePiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event SourcePiece m (Maybe UTCTime)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe UTCTime)
tagDate Text
"updated"
          ]


data EntryPiece = EntryAuthor { EntryPiece -> AtomPerson
__entryAuthor ::      AtomPerson }
                | EntryCategory { EntryPiece -> AtomCategory
__entryCategory ::     AtomCategory }
                | EntryContent { EntryPiece -> AtomContent
__entryContent :: AtomContent }
                | EntryContributor { EntryPiece -> AtomPerson
__entryContributor :: AtomPerson }
                | EntryId { EntryPiece -> Text
__entryId :: Text }
                | EntryLink { EntryPiece -> AtomLink
__entryLink :: AtomLink }
                | EntryPublished { EntryPiece -> UTCTime
__entryPublished :: UTCTime }
                | EntryRights { EntryPiece -> AtomText
__entryRights :: AtomText }
                | EntrySource { EntryPiece -> AtomSource
__entrySource :: AtomSource }
                | EntrySummary { EntryPiece -> AtomText
__entrySummary :: AtomText }
                | EntryTitle { EntryPiece -> AtomText
__entryTitle :: AtomText }
                | EntryUpdated { EntryPiece -> UTCTime
__entryUpdated :: UTCTime }

makeLenses ''EntryPiece

-- | Parse an @atom:entry@ element.
atomEntry :: MonadThrow m => ConduitM Event o m (Maybe AtomEntry)
atomEntry :: ConduitM Event o m (Maybe AtomEntry)
atomEntry = Text
-> ConduitM Event o m AtomEntry
-> ConduitM Event o m (Maybe AtomEntry)
forall (m :: * -> *) o a.
MonadThrow m =>
Text -> ConduitM Event o m a -> ConduitM Event o m (Maybe a)
tagIgnoreAttrs' Text
"entry" (ConduitM Event o m AtomEntry
 -> ConduitM Event o m (Maybe AtomEntry))
-> ConduitM Event o m AtomEntry
-> ConduitM Event o m (Maybe AtomEntry)
forall a b. (a -> b) -> a -> b
$ ConduitT Event EntryPiece m (Maybe EntryPiece)
-> ConduitT Event EntryPiece m ()
forall (m :: * -> *) b.
MonadThrow m =>
ConduitT Event b m (Maybe b) -> ConduitT Event b m ()
manyYield' ([ConduitT Event EntryPiece m (Maybe EntryPiece)]
-> ConduitT Event EntryPiece m (Maybe EntryPiece)
forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose [ConduitT Event EntryPiece m (Maybe EntryPiece)]
piece) ConduitT Event EntryPiece m ()
-> ConduitM EntryPiece o m AtomEntry
-> ConduitM Event o m AtomEntry
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM EntryPiece o m AtomEntry
forall o. ConduitT EntryPiece o m AtomEntry
zipConduit where
  zipConduit :: ConduitT EntryPiece o m AtomEntry
zipConduit = ZipConduit EntryPiece o m AtomEntry
-> ConduitT EntryPiece o m AtomEntry
forall i o (m :: * -> *) r. ZipConduit i o m r -> ConduitT i o m r
getZipConduit (ZipConduit EntryPiece o m AtomEntry
 -> ConduitT EntryPiece o m AtomEntry)
-> ZipConduit EntryPiece o m AtomEntry
-> ConduitT EntryPiece o m AtomEntry
forall a b. (a -> b) -> a -> b
$ [AtomPerson]
-> [AtomCategory]
-> Maybe AtomContent
-> [AtomPerson]
-> Text
-> [AtomLink]
-> Maybe UTCTime
-> Maybe AtomText
-> Maybe AtomSource
-> Maybe AtomText
-> AtomText
-> UTCTime
-> AtomEntry
AtomEntry
    ([AtomPerson]
 -> [AtomCategory]
 -> Maybe AtomContent
 -> [AtomPerson]
 -> Text
 -> [AtomLink]
 -> Maybe UTCTime
 -> Maybe AtomText
 -> Maybe AtomSource
 -> Maybe AtomText
 -> AtomText
 -> UTCTime
 -> AtomEntry)
-> ZipConduit EntryPiece o m [AtomPerson]
-> ZipConduit
     EntryPiece
     o
     m
     ([AtomCategory]
      -> Maybe AtomContent
      -> [AtomPerson]
      -> Text
      -> [AtomLink]
      -> Maybe UTCTime
      -> Maybe AtomText
      -> Maybe AtomSource
      -> Maybe AtomText
      -> AtomText
      -> UTCTime
      -> AtomEntry)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT EntryPiece o m [AtomPerson]
-> ZipConduit EntryPiece o m [AtomPerson]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' EntryPiece AtomPerson
-> ConduitT EntryPiece AtomPerson m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' EntryPiece AtomPerson
_entryAuthor ConduitT EntryPiece AtomPerson m ()
-> ConduitM AtomPerson o m [AtomPerson]
-> ConduitT EntryPiece o m [AtomPerson]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomPerson o m [AtomPerson]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  EntryPiece
  o
  m
  ([AtomCategory]
   -> Maybe AtomContent
   -> [AtomPerson]
   -> Text
   -> [AtomLink]
   -> Maybe UTCTime
   -> Maybe AtomText
   -> Maybe AtomSource
   -> Maybe AtomText
   -> AtomText
   -> UTCTime
   -> AtomEntry)
-> ZipConduit EntryPiece o m [AtomCategory]
-> ZipConduit
     EntryPiece
     o
     m
     (Maybe AtomContent
      -> [AtomPerson]
      -> Text
      -> [AtomLink]
      -> Maybe UTCTime
      -> Maybe AtomText
      -> Maybe AtomSource
      -> Maybe AtomText
      -> AtomText
      -> UTCTime
      -> AtomEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT EntryPiece o m [AtomCategory]
-> ZipConduit EntryPiece o m [AtomCategory]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' EntryPiece AtomCategory
-> ConduitT EntryPiece AtomCategory m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' EntryPiece AtomCategory
_entryCategory ConduitT EntryPiece AtomCategory m ()
-> ConduitM AtomCategory o m [AtomCategory]
-> ConduitT EntryPiece o m [AtomCategory]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomCategory o m [AtomCategory]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  EntryPiece
  o
  m
  (Maybe AtomContent
   -> [AtomPerson]
   -> Text
   -> [AtomLink]
   -> Maybe UTCTime
   -> Maybe AtomText
   -> Maybe AtomSource
   -> Maybe AtomText
   -> AtomText
   -> UTCTime
   -> AtomEntry)
-> ZipConduit EntryPiece o m (Maybe AtomContent)
-> ZipConduit
     EntryPiece
     o
     m
     ([AtomPerson]
      -> Text
      -> [AtomLink]
      -> Maybe UTCTime
      -> Maybe AtomText
      -> Maybe AtomSource
      -> Maybe AtomText
      -> AtomText
      -> UTCTime
      -> AtomEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT EntryPiece o m (Maybe AtomContent)
-> ZipConduit EntryPiece o m (Maybe AtomContent)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' EntryPiece AtomContent
-> ConduitT EntryPiece AtomContent m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' EntryPiece AtomContent
_entryContent ConduitT EntryPiece AtomContent m ()
-> ConduitM AtomContent o m (Maybe AtomContent)
-> ConduitT EntryPiece o m (Maybe AtomContent)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomContent o m (Maybe AtomContent)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  EntryPiece
  o
  m
  ([AtomPerson]
   -> Text
   -> [AtomLink]
   -> Maybe UTCTime
   -> Maybe AtomText
   -> Maybe AtomSource
   -> Maybe AtomText
   -> AtomText
   -> UTCTime
   -> AtomEntry)
-> ZipConduit EntryPiece o m [AtomPerson]
-> ZipConduit
     EntryPiece
     o
     m
     (Text
      -> [AtomLink]
      -> Maybe UTCTime
      -> Maybe AtomText
      -> Maybe AtomSource
      -> Maybe AtomText
      -> AtomText
      -> UTCTime
      -> AtomEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT EntryPiece o m [AtomPerson]
-> ZipConduit EntryPiece o m [AtomPerson]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' EntryPiece AtomPerson
-> ConduitT EntryPiece AtomPerson m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' EntryPiece AtomPerson
_entryContributor ConduitT EntryPiece AtomPerson m ()
-> ConduitM AtomPerson o m [AtomPerson]
-> ConduitT EntryPiece o m [AtomPerson]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomPerson o m [AtomPerson]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  EntryPiece
  o
  m
  (Text
   -> [AtomLink]
   -> Maybe UTCTime
   -> Maybe AtomText
   -> Maybe AtomSource
   -> Maybe AtomText
   -> AtomText
   -> UTCTime
   -> AtomEntry)
-> ZipConduit EntryPiece o m Text
-> ZipConduit
     EntryPiece
     o
     m
     ([AtomLink]
      -> Maybe UTCTime
      -> Maybe AtomText
      -> Maybe AtomSource
      -> Maybe AtomText
      -> AtomText
      -> UTCTime
      -> AtomEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT EntryPiece o m Text -> ZipConduit EntryPiece o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' EntryPiece Text -> ConduitT EntryPiece Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' EntryPiece Text
_entryId ConduitT EntryPiece Text m ()
-> ConduitM Text o m Text -> ConduitT EntryPiece 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. MonadThrow m => Text -> ConduitT a o m a
headRequiredC Text
"Missing <id> element")
    ZipConduit
  EntryPiece
  o
  m
  ([AtomLink]
   -> Maybe UTCTime
   -> Maybe AtomText
   -> Maybe AtomSource
   -> Maybe AtomText
   -> AtomText
   -> UTCTime
   -> AtomEntry)
-> ZipConduit EntryPiece o m [AtomLink]
-> ZipConduit
     EntryPiece
     o
     m
     (Maybe UTCTime
      -> Maybe AtomText
      -> Maybe AtomSource
      -> Maybe AtomText
      -> AtomText
      -> UTCTime
      -> AtomEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT EntryPiece o m [AtomLink]
-> ZipConduit EntryPiece o m [AtomLink]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' EntryPiece AtomLink -> ConduitT EntryPiece AtomLink m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' EntryPiece AtomLink
_entryLink ConduitT EntryPiece AtomLink m ()
-> ConduitM AtomLink o m [AtomLink]
-> ConduitT EntryPiece o m [AtomLink]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomLink o m [AtomLink]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  EntryPiece
  o
  m
  (Maybe UTCTime
   -> Maybe AtomText
   -> Maybe AtomSource
   -> Maybe AtomText
   -> AtomText
   -> UTCTime
   -> AtomEntry)
-> ZipConduit EntryPiece o m (Maybe UTCTime)
-> ZipConduit
     EntryPiece
     o
     m
     (Maybe AtomText
      -> Maybe AtomSource
      -> Maybe AtomText
      -> AtomText
      -> UTCTime
      -> AtomEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT EntryPiece o m (Maybe UTCTime)
-> ZipConduit EntryPiece o m (Maybe UTCTime)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' EntryPiece UTCTime -> ConduitT EntryPiece UTCTime m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' EntryPiece UTCTime
_entryPublished ConduitT EntryPiece UTCTime m ()
-> ConduitM UTCTime o m (Maybe UTCTime)
-> ConduitT EntryPiece 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
  EntryPiece
  o
  m
  (Maybe AtomText
   -> Maybe AtomSource
   -> Maybe AtomText
   -> AtomText
   -> UTCTime
   -> AtomEntry)
-> ZipConduit EntryPiece o m (Maybe AtomText)
-> ZipConduit
     EntryPiece
     o
     m
     (Maybe AtomSource
      -> Maybe AtomText -> AtomText -> UTCTime -> AtomEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT EntryPiece o m (Maybe AtomText)
-> ZipConduit EntryPiece o m (Maybe AtomText)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' EntryPiece AtomText -> ConduitT EntryPiece AtomText m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' EntryPiece AtomText
_entryRights ConduitT EntryPiece AtomText m ()
-> ConduitM AtomText o m (Maybe AtomText)
-> ConduitT EntryPiece o m (Maybe AtomText)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomText o m (Maybe AtomText)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  EntryPiece
  o
  m
  (Maybe AtomSource
   -> Maybe AtomText -> AtomText -> UTCTime -> AtomEntry)
-> ZipConduit EntryPiece o m (Maybe AtomSource)
-> ZipConduit
     EntryPiece o m (Maybe AtomText -> AtomText -> UTCTime -> AtomEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT EntryPiece o m (Maybe AtomSource)
-> ZipConduit EntryPiece o m (Maybe AtomSource)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' EntryPiece AtomSource
-> ConduitT EntryPiece AtomSource m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' EntryPiece AtomSource
_entrySource ConduitT EntryPiece AtomSource m ()
-> ConduitM AtomSource o m (Maybe AtomSource)
-> ConduitT EntryPiece o m (Maybe AtomSource)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomSource o m (Maybe AtomSource)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  EntryPiece o m (Maybe AtomText -> AtomText -> UTCTime -> AtomEntry)
-> ZipConduit EntryPiece o m (Maybe AtomText)
-> ZipConduit EntryPiece o m (AtomText -> UTCTime -> AtomEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT EntryPiece o m (Maybe AtomText)
-> ZipConduit EntryPiece o m (Maybe AtomText)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' EntryPiece AtomText -> ConduitT EntryPiece AtomText m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' EntryPiece AtomText
_entrySummary ConduitT EntryPiece AtomText m ()
-> ConduitM AtomText o m (Maybe AtomText)
-> ConduitT EntryPiece o m (Maybe AtomText)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomText o m (Maybe AtomText)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit EntryPiece o m (AtomText -> UTCTime -> AtomEntry)
-> ZipConduit EntryPiece o m AtomText
-> ZipConduit EntryPiece o m (UTCTime -> AtomEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT EntryPiece o m AtomText
-> ZipConduit EntryPiece o m AtomText
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' EntryPiece AtomText -> ConduitT EntryPiece AtomText m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' EntryPiece AtomText
_entryTitle ConduitT EntryPiece AtomText m ()
-> ConduitM AtomText o m AtomText
-> ConduitT EntryPiece o m AtomText
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM AtomText o m AtomText
forall (m :: * -> *) a o. MonadThrow m => Text -> ConduitT a o m a
headRequiredC Text
"Missing or invalid <title> element.")
    ZipConduit EntryPiece o m (UTCTime -> AtomEntry)
-> ZipConduit EntryPiece o m UTCTime
-> ZipConduit EntryPiece o m AtomEntry
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT EntryPiece o m UTCTime
-> ZipConduit EntryPiece o m UTCTime
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' EntryPiece UTCTime -> ConduitT EntryPiece UTCTime m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' EntryPiece UTCTime
_entryUpdated ConduitT EntryPiece UTCTime m ()
-> ConduitM UTCTime o m UTCTime -> ConduitT EntryPiece o m UTCTime
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM UTCTime o m UTCTime
forall (m :: * -> *) a o. MonadThrow m => Text -> ConduitT a o m a
headRequiredC Text
"Missing or invalid <updated> element.")
  piece :: [ConduitT Event EntryPiece m (Maybe EntryPiece)]
piece = [ (AtomPerson -> EntryPiece) -> Maybe AtomPerson -> Maybe EntryPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomPerson -> EntryPiece
EntryAuthor (Maybe AtomPerson -> Maybe EntryPiece)
-> ConduitT Event EntryPiece m (Maybe AtomPerson)
-> ConduitT Event EntryPiece m (Maybe EntryPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event EntryPiece m (Maybe AtomPerson)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe AtomPerson)
atomPerson Text
"author"
          , (AtomCategory -> EntryPiece)
-> Maybe AtomCategory -> Maybe EntryPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomCategory -> EntryPiece
EntryCategory (Maybe AtomCategory -> Maybe EntryPiece)
-> ConduitT Event EntryPiece m (Maybe AtomCategory)
-> ConduitT Event EntryPiece m (Maybe EntryPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event EntryPiece m (Maybe AtomCategory)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomCategory)
atomCategory
          , (AtomContent -> EntryPiece)
-> Maybe AtomContent -> Maybe EntryPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomContent -> EntryPiece
EntryContent (Maybe AtomContent -> Maybe EntryPiece)
-> ConduitT Event EntryPiece m (Maybe AtomContent)
-> ConduitT Event EntryPiece m (Maybe EntryPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event EntryPiece m (Maybe AtomContent)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomContent)
atomContent
          , (AtomPerson -> EntryPiece) -> Maybe AtomPerson -> Maybe EntryPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomPerson -> EntryPiece
EntryContributor (Maybe AtomPerson -> Maybe EntryPiece)
-> ConduitT Event EntryPiece m (Maybe AtomPerson)
-> ConduitT Event EntryPiece m (Maybe EntryPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event EntryPiece m (Maybe AtomPerson)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe AtomPerson)
atomPerson Text
"contributor"
          , (Text -> EntryPiece) -> Maybe Text -> Maybe EntryPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> EntryPiece
EntryId (Maybe Text -> Maybe EntryPiece)
-> ConduitT Event EntryPiece m (Maybe Text)
-> ConduitT Event EntryPiece m (Maybe EntryPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event EntryPiece m (Maybe Text)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe Text)
atomId
          , (AtomLink -> EntryPiece) -> Maybe AtomLink -> Maybe EntryPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomLink -> EntryPiece
EntryLink (Maybe AtomLink -> Maybe EntryPiece)
-> ConduitT Event EntryPiece m (Maybe AtomLink)
-> ConduitT Event EntryPiece m (Maybe EntryPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event EntryPiece m (Maybe AtomLink)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomLink)
atomLink
          , (UTCTime -> EntryPiece) -> Maybe UTCTime -> Maybe EntryPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap UTCTime -> EntryPiece
EntryPublished (Maybe UTCTime -> Maybe EntryPiece)
-> ConduitT Event EntryPiece m (Maybe UTCTime)
-> ConduitT Event EntryPiece m (Maybe EntryPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event EntryPiece m (Maybe UTCTime)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe UTCTime)
tagDate Text
"published"
          , (AtomText -> EntryPiece) -> Maybe AtomText -> Maybe EntryPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomText -> EntryPiece
EntryRights (Maybe AtomText -> Maybe EntryPiece)
-> ConduitT Event EntryPiece m (Maybe AtomText)
-> ConduitT Event EntryPiece m (Maybe EntryPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event EntryPiece m (Maybe AtomText)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe AtomText)
atomText Text
"rights"
          , (AtomSource -> EntryPiece) -> Maybe AtomSource -> Maybe EntryPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomSource -> EntryPiece
EntrySource (Maybe AtomSource -> Maybe EntryPiece)
-> ConduitT Event EntryPiece m (Maybe AtomSource)
-> ConduitT Event EntryPiece m (Maybe EntryPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event EntryPiece m (Maybe AtomSource)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomSource)
atomSource
          , (AtomText -> EntryPiece) -> Maybe AtomText -> Maybe EntryPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomText -> EntryPiece
EntrySummary (Maybe AtomText -> Maybe EntryPiece)
-> ConduitT Event EntryPiece m (Maybe AtomText)
-> ConduitT Event EntryPiece m (Maybe EntryPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event EntryPiece m (Maybe AtomText)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe AtomText)
atomText Text
"summary"
          , (AtomText -> EntryPiece) -> Maybe AtomText -> Maybe EntryPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomText -> EntryPiece
EntryTitle (Maybe AtomText -> Maybe EntryPiece)
-> ConduitT Event EntryPiece m (Maybe AtomText)
-> ConduitT Event EntryPiece m (Maybe EntryPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event EntryPiece m (Maybe AtomText)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe AtomText)
atomText Text
"title"
          , (UTCTime -> EntryPiece) -> Maybe UTCTime -> Maybe EntryPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap UTCTime -> EntryPiece
EntryUpdated (Maybe UTCTime -> Maybe EntryPiece)
-> ConduitT Event EntryPiece m (Maybe UTCTime)
-> ConduitT Event EntryPiece m (Maybe EntryPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event EntryPiece m (Maybe UTCTime)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe UTCTime)
tagDate Text
"updated"
          ]


data FeedPiece = FeedAuthor { FeedPiece -> AtomPerson
__feedAuthor :: AtomPerson }
               | FeedCategory { FeedPiece -> AtomCategory
__feedCategory :: AtomCategory }
               | FeedContributor { FeedPiece -> AtomPerson
__feedContributor :: AtomPerson }
               | FeedEntry { FeedPiece -> AtomEntry
__feedEntry :: AtomEntry }
               | FeedGenerator { FeedPiece -> AtomGenerator
__feedGenerator :: AtomGenerator }
               | FeedIcon { FeedPiece -> AtomURI
__feedIcon :: AtomURI }
               | FeedId { FeedPiece -> Text
__feedId :: Text }
               | FeedLink { FeedPiece -> AtomLink
__feedLink :: AtomLink }
               |  {  :: AtomURI }
               | FeedRights { FeedPiece -> AtomText
__feedRights :: AtomText }
               | FeedSubtitle { FeedPiece -> AtomText
__feedSubtitle :: AtomText }
               | FeedTitle { FeedPiece -> AtomText
__feedTitle :: AtomText }
               | FeedUpdated { FeedPiece -> UTCTime
__feedUpdated :: UTCTime }



-- | Parse an @atom:feed@ element.
atomFeed :: MonadThrow m => ConduitM Event o m (Maybe AtomFeed)
atomFeed :: ConduitM Event o m (Maybe AtomFeed)
atomFeed = Text
-> ConduitM Event o m AtomFeed
-> ConduitM Event o m (Maybe AtomFeed)
forall (m :: * -> *) o a.
MonadThrow m =>
Text -> ConduitM Event o m a -> ConduitM Event o m (Maybe a)
tagIgnoreAttrs' Text
"feed" (ConduitM Event o m AtomFeed
 -> ConduitM Event o m (Maybe AtomFeed))
-> ConduitM Event o m AtomFeed
-> ConduitM Event o m (Maybe AtomFeed)
forall a b. (a -> b) -> a -> b
$ ConduitT Event FeedPiece m (Maybe FeedPiece)
-> ConduitT Event FeedPiece m ()
forall (m :: * -> *) b.
MonadThrow m =>
ConduitT Event b m (Maybe b) -> ConduitT Event b m ()
manyYield' ([ConduitT Event FeedPiece m (Maybe FeedPiece)]
-> ConduitT Event FeedPiece m (Maybe FeedPiece)
forall (m :: * -> *) o a.
Monad m =>
[ConduitT Event o m (Maybe a)] -> ConduitT Event o m (Maybe a)
choose [ConduitT Event FeedPiece m (Maybe FeedPiece)]
piece) ConduitT Event FeedPiece m ()
-> ConduitM FeedPiece o m AtomFeed -> ConduitM Event o m AtomFeed
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM FeedPiece o m AtomFeed
forall o. ConduitT FeedPiece o m AtomFeed
zipConduit where
  zipConduit :: ConduitT FeedPiece o m AtomFeed
zipConduit = ZipConduit FeedPiece o m AtomFeed
-> ConduitT FeedPiece o m AtomFeed
forall i o (m :: * -> *) r. ZipConduit i o m r -> ConduitT i o m r
getZipConduit (ZipConduit FeedPiece o m AtomFeed
 -> ConduitT FeedPiece o m AtomFeed)
-> ZipConduit FeedPiece o m AtomFeed
-> ConduitT FeedPiece o m AtomFeed
forall a b. (a -> b) -> a -> b
$ [AtomPerson]
-> [AtomCategory]
-> [AtomPerson]
-> [AtomEntry]
-> Maybe AtomGenerator
-> Maybe AtomURI
-> Text
-> [AtomLink]
-> Maybe AtomURI
-> Maybe AtomText
-> Maybe AtomText
-> AtomText
-> UTCTime
-> AtomFeed
AtomFeed
    ([AtomPerson]
 -> [AtomCategory]
 -> [AtomPerson]
 -> [AtomEntry]
 -> Maybe AtomGenerator
 -> Maybe AtomURI
 -> Text
 -> [AtomLink]
 -> Maybe AtomURI
 -> Maybe AtomText
 -> Maybe AtomText
 -> AtomText
 -> UTCTime
 -> AtomFeed)
-> ZipConduit FeedPiece o m [AtomPerson]
-> ZipConduit
     FeedPiece
     o
     m
     ([AtomCategory]
      -> [AtomPerson]
      -> [AtomEntry]
      -> Maybe AtomGenerator
      -> Maybe AtomURI
      -> Text
      -> [AtomLink]
      -> Maybe AtomURI
      -> Maybe AtomText
      -> Maybe AtomText
      -> AtomText
      -> UTCTime
      -> AtomFeed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT FeedPiece o m [AtomPerson]
-> ZipConduit FeedPiece o m [AtomPerson]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' FeedPiece AtomPerson
-> ConduitT FeedPiece AtomPerson m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' FeedPiece AtomPerson
_feedAuthor ConduitT FeedPiece AtomPerson m ()
-> ConduitM AtomPerson o m [AtomPerson]
-> ConduitT FeedPiece o m [AtomPerson]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomPerson o m [AtomPerson]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  FeedPiece
  o
  m
  ([AtomCategory]
   -> [AtomPerson]
   -> [AtomEntry]
   -> Maybe AtomGenerator
   -> Maybe AtomURI
   -> Text
   -> [AtomLink]
   -> Maybe AtomURI
   -> Maybe AtomText
   -> Maybe AtomText
   -> AtomText
   -> UTCTime
   -> AtomFeed)
-> ZipConduit FeedPiece o m [AtomCategory]
-> ZipConduit
     FeedPiece
     o
     m
     ([AtomPerson]
      -> [AtomEntry]
      -> Maybe AtomGenerator
      -> Maybe AtomURI
      -> Text
      -> [AtomLink]
      -> Maybe AtomURI
      -> Maybe AtomText
      -> Maybe AtomText
      -> AtomText
      -> UTCTime
      -> AtomFeed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT FeedPiece o m [AtomCategory]
-> ZipConduit FeedPiece o m [AtomCategory]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' FeedPiece AtomCategory
-> ConduitT FeedPiece AtomCategory m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' FeedPiece AtomCategory
_feedCategory ConduitT FeedPiece AtomCategory m ()
-> ConduitM AtomCategory o m [AtomCategory]
-> ConduitT FeedPiece o m [AtomCategory]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomCategory o m [AtomCategory]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  FeedPiece
  o
  m
  ([AtomPerson]
   -> [AtomEntry]
   -> Maybe AtomGenerator
   -> Maybe AtomURI
   -> Text
   -> [AtomLink]
   -> Maybe AtomURI
   -> Maybe AtomText
   -> Maybe AtomText
   -> AtomText
   -> UTCTime
   -> AtomFeed)
-> ZipConduit FeedPiece o m [AtomPerson]
-> ZipConduit
     FeedPiece
     o
     m
     ([AtomEntry]
      -> Maybe AtomGenerator
      -> Maybe AtomURI
      -> Text
      -> [AtomLink]
      -> Maybe AtomURI
      -> Maybe AtomText
      -> Maybe AtomText
      -> AtomText
      -> UTCTime
      -> AtomFeed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT FeedPiece o m [AtomPerson]
-> ZipConduit FeedPiece o m [AtomPerson]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' FeedPiece AtomPerson
-> ConduitT FeedPiece AtomPerson m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' FeedPiece AtomPerson
_feedContributor ConduitT FeedPiece AtomPerson m ()
-> ConduitM AtomPerson o m [AtomPerson]
-> ConduitT FeedPiece o m [AtomPerson]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomPerson o m [AtomPerson]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  FeedPiece
  o
  m
  ([AtomEntry]
   -> Maybe AtomGenerator
   -> Maybe AtomURI
   -> Text
   -> [AtomLink]
   -> Maybe AtomURI
   -> Maybe AtomText
   -> Maybe AtomText
   -> AtomText
   -> UTCTime
   -> AtomFeed)
-> ZipConduit FeedPiece o m [AtomEntry]
-> ZipConduit
     FeedPiece
     o
     m
     (Maybe AtomGenerator
      -> Maybe AtomURI
      -> Text
      -> [AtomLink]
      -> Maybe AtomURI
      -> Maybe AtomText
      -> Maybe AtomText
      -> AtomText
      -> UTCTime
      -> AtomFeed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT FeedPiece o m [AtomEntry]
-> ZipConduit FeedPiece o m [AtomEntry]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' FeedPiece AtomEntry -> ConduitT FeedPiece AtomEntry m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' FeedPiece AtomEntry
_feedEntry ConduitT FeedPiece AtomEntry m ()
-> ConduitM AtomEntry o m [AtomEntry]
-> ConduitT FeedPiece o m [AtomEntry]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomEntry o m [AtomEntry]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  FeedPiece
  o
  m
  (Maybe AtomGenerator
   -> Maybe AtomURI
   -> Text
   -> [AtomLink]
   -> Maybe AtomURI
   -> Maybe AtomText
   -> Maybe AtomText
   -> AtomText
   -> UTCTime
   -> AtomFeed)
-> ZipConduit FeedPiece o m (Maybe AtomGenerator)
-> ZipConduit
     FeedPiece
     o
     m
     (Maybe AtomURI
      -> Text
      -> [AtomLink]
      -> Maybe AtomURI
      -> Maybe AtomText
      -> Maybe AtomText
      -> AtomText
      -> UTCTime
      -> AtomFeed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT FeedPiece o m (Maybe AtomGenerator)
-> ZipConduit FeedPiece o m (Maybe AtomGenerator)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' FeedPiece AtomGenerator
-> ConduitT FeedPiece AtomGenerator m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' FeedPiece AtomGenerator
_feedGenerator ConduitT FeedPiece AtomGenerator m ()
-> ConduitM AtomGenerator o m (Maybe AtomGenerator)
-> ConduitT FeedPiece o m (Maybe AtomGenerator)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomGenerator o m (Maybe AtomGenerator)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  FeedPiece
  o
  m
  (Maybe AtomURI
   -> Text
   -> [AtomLink]
   -> Maybe AtomURI
   -> Maybe AtomText
   -> Maybe AtomText
   -> AtomText
   -> UTCTime
   -> AtomFeed)
-> ZipConduit FeedPiece o m (Maybe AtomURI)
-> ZipConduit
     FeedPiece
     o
     m
     (Text
      -> [AtomLink]
      -> Maybe AtomURI
      -> Maybe AtomText
      -> Maybe AtomText
      -> AtomText
      -> UTCTime
      -> AtomFeed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT FeedPiece o m (Maybe AtomURI)
-> ZipConduit FeedPiece o m (Maybe AtomURI)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' FeedPiece AtomURI -> ConduitT FeedPiece AtomURI m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' FeedPiece AtomURI
_feedIcon ConduitT FeedPiece AtomURI m ()
-> ConduitM AtomURI o m (Maybe AtomURI)
-> ConduitT FeedPiece o m (Maybe AtomURI)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomURI o m (Maybe AtomURI)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  FeedPiece
  o
  m
  (Text
   -> [AtomLink]
   -> Maybe AtomURI
   -> Maybe AtomText
   -> Maybe AtomText
   -> AtomText
   -> UTCTime
   -> AtomFeed)
-> ZipConduit FeedPiece o m Text
-> ZipConduit
     FeedPiece
     o
     m
     ([AtomLink]
      -> Maybe AtomURI
      -> Maybe AtomText
      -> Maybe AtomText
      -> AtomText
      -> UTCTime
      -> AtomFeed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT FeedPiece o m Text -> ZipConduit FeedPiece o m Text
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' FeedPiece Text -> ConduitT FeedPiece Text m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' FeedPiece Text
_feedId ConduitT FeedPiece Text m ()
-> ConduitM Text o m Text -> ConduitT FeedPiece 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. MonadThrow m => Text -> ConduitT a o m a
headRequiredC Text
"Missing <id> element")
    ZipConduit
  FeedPiece
  o
  m
  ([AtomLink]
   -> Maybe AtomURI
   -> Maybe AtomText
   -> Maybe AtomText
   -> AtomText
   -> UTCTime
   -> AtomFeed)
-> ZipConduit FeedPiece o m [AtomLink]
-> ZipConduit
     FeedPiece
     o
     m
     (Maybe AtomURI
      -> Maybe AtomText
      -> Maybe AtomText
      -> AtomText
      -> UTCTime
      -> AtomFeed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT FeedPiece o m [AtomLink]
-> ZipConduit FeedPiece o m [AtomLink]
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' FeedPiece AtomLink -> ConduitT FeedPiece AtomLink m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' FeedPiece AtomLink
_feedLink ConduitT FeedPiece AtomLink m ()
-> ConduitM AtomLink o m [AtomLink]
-> ConduitT FeedPiece o m [AtomLink]
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomLink o m [AtomLink]
forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
sinkList)
    ZipConduit
  FeedPiece
  o
  m
  (Maybe AtomURI
   -> Maybe AtomText
   -> Maybe AtomText
   -> AtomText
   -> UTCTime
   -> AtomFeed)
-> ZipConduit FeedPiece o m (Maybe AtomURI)
-> ZipConduit
     FeedPiece
     o
     m
     (Maybe AtomText
      -> Maybe AtomText -> AtomText -> UTCTime -> AtomFeed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT FeedPiece o m (Maybe AtomURI)
-> ZipConduit FeedPiece o m (Maybe AtomURI)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' FeedPiece AtomURI -> ConduitT FeedPiece AtomURI m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' FeedPiece AtomURI
_feedLogo ConduitT FeedPiece AtomURI m ()
-> ConduitM AtomURI o m (Maybe AtomURI)
-> ConduitT FeedPiece o m (Maybe AtomURI)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomURI o m (Maybe AtomURI)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  FeedPiece
  o
  m
  (Maybe AtomText
   -> Maybe AtomText -> AtomText -> UTCTime -> AtomFeed)
-> ZipConduit FeedPiece o m (Maybe AtomText)
-> ZipConduit
     FeedPiece o m (Maybe AtomText -> AtomText -> UTCTime -> AtomFeed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT FeedPiece o m (Maybe AtomText)
-> ZipConduit FeedPiece o m (Maybe AtomText)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' FeedPiece AtomText -> ConduitT FeedPiece AtomText m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' FeedPiece AtomText
_feedRights ConduitT FeedPiece AtomText m ()
-> ConduitM AtomText o m (Maybe AtomText)
-> ConduitT FeedPiece o m (Maybe AtomText)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomText o m (Maybe AtomText)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit
  FeedPiece o m (Maybe AtomText -> AtomText -> UTCTime -> AtomFeed)
-> ZipConduit FeedPiece o m (Maybe AtomText)
-> ZipConduit FeedPiece o m (AtomText -> UTCTime -> AtomFeed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT FeedPiece o m (Maybe AtomText)
-> ZipConduit FeedPiece o m (Maybe AtomText)
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' FeedPiece AtomText -> ConduitT FeedPiece AtomText m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' FeedPiece AtomText
_feedSubtitle ConduitT FeedPiece AtomText m ()
-> ConduitM AtomText o m (Maybe AtomText)
-> ConduitT FeedPiece o m (Maybe AtomText)
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| ConduitM AtomText o m (Maybe AtomText)
forall (m :: * -> *) a o. Monad m => ConduitT a o m (Maybe a)
headC)
    ZipConduit FeedPiece o m (AtomText -> UTCTime -> AtomFeed)
-> ZipConduit FeedPiece o m AtomText
-> ZipConduit FeedPiece o m (UTCTime -> AtomFeed)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT FeedPiece o m AtomText
-> ZipConduit FeedPiece o m AtomText
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' FeedPiece AtomText -> ConduitT FeedPiece AtomText m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' FeedPiece AtomText
_feedTitle ConduitT FeedPiece AtomText m ()
-> ConduitM AtomText o m AtomText
-> ConduitT FeedPiece o m AtomText
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM AtomText o m AtomText
forall (m :: * -> *) a o. MonadThrow m => Text -> ConduitT a o m a
headRequiredC Text
"Missing <title> element.")
    ZipConduit FeedPiece o m (UTCTime -> AtomFeed)
-> ZipConduit FeedPiece o m UTCTime
-> ZipConduit FeedPiece o m AtomFeed
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ConduitT FeedPiece o m UTCTime -> ZipConduit FeedPiece o m UTCTime
forall i o (m :: * -> *) r. ConduitT i o m r -> ZipConduit i o m r
ZipConduit (Traversal' FeedPiece UTCTime -> ConduitT FeedPiece UTCTime m ()
forall (m :: * -> *) a b.
Monad m =>
Traversal' a b -> ConduitT a b m ()
projectC Traversal' FeedPiece UTCTime
_feedUpdated ConduitT FeedPiece UTCTime m ()
-> ConduitM UTCTime o m UTCTime -> ConduitT FeedPiece o m UTCTime
forall (m :: * -> *) a b c r.
Monad m =>
ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r
.| Text -> ConduitM UTCTime o m UTCTime
forall (m :: * -> *) a o. MonadThrow m => Text -> ConduitT a o m a
headRequiredC Text
"Missing <updated> element.")
  piece :: [ConduitT Event FeedPiece m (Maybe FeedPiece)]
piece = [ (AtomPerson -> FeedPiece) -> Maybe AtomPerson -> Maybe FeedPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomPerson -> FeedPiece
FeedAuthor (Maybe AtomPerson -> Maybe FeedPiece)
-> ConduitT Event FeedPiece m (Maybe AtomPerson)
-> ConduitT Event FeedPiece m (Maybe FeedPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event FeedPiece m (Maybe AtomPerson)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe AtomPerson)
atomPerson Text
"author"
          , (AtomCategory -> FeedPiece)
-> Maybe AtomCategory -> Maybe FeedPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomCategory -> FeedPiece
FeedCategory (Maybe AtomCategory -> Maybe FeedPiece)
-> ConduitT Event FeedPiece m (Maybe AtomCategory)
-> ConduitT Event FeedPiece m (Maybe FeedPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event FeedPiece m (Maybe AtomCategory)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomCategory)
atomCategory
          , (AtomPerson -> FeedPiece) -> Maybe AtomPerson -> Maybe FeedPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomPerson -> FeedPiece
FeedContributor (Maybe AtomPerson -> Maybe FeedPiece)
-> ConduitT Event FeedPiece m (Maybe AtomPerson)
-> ConduitT Event FeedPiece m (Maybe FeedPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event FeedPiece m (Maybe AtomPerson)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe AtomPerson)
atomPerson Text
"contributor"
          , (AtomEntry -> FeedPiece) -> Maybe AtomEntry -> Maybe FeedPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomEntry -> FeedPiece
FeedEntry (Maybe AtomEntry -> Maybe FeedPiece)
-> ConduitT Event FeedPiece m (Maybe AtomEntry)
-> ConduitT Event FeedPiece m (Maybe FeedPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event FeedPiece m (Maybe AtomEntry)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomEntry)
atomEntry
          , (AtomGenerator -> FeedPiece)
-> Maybe AtomGenerator -> Maybe FeedPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomGenerator -> FeedPiece
FeedGenerator (Maybe AtomGenerator -> Maybe FeedPiece)
-> ConduitT Event FeedPiece m (Maybe AtomGenerator)
-> ConduitT Event FeedPiece m (Maybe FeedPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event FeedPiece m (Maybe AtomGenerator)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomGenerator)
atomGenerator
          , (AtomURI -> FeedPiece) -> Maybe AtomURI -> Maybe FeedPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomURI -> FeedPiece
FeedIcon (Maybe AtomURI -> Maybe FeedPiece)
-> ConduitT Event FeedPiece m (Maybe AtomURI)
-> ConduitT Event FeedPiece m (Maybe FeedPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event FeedPiece m (Maybe AtomURI)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomURI)
atomIcon
          , (Text -> FeedPiece) -> Maybe Text -> Maybe FeedPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> FeedPiece
FeedId (Maybe Text -> Maybe FeedPiece)
-> ConduitT Event FeedPiece m (Maybe Text)
-> ConduitT Event FeedPiece m (Maybe FeedPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event FeedPiece m (Maybe Text)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe Text)
atomId
          , (AtomLink -> FeedPiece) -> Maybe AtomLink -> Maybe FeedPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomLink -> FeedPiece
FeedLink (Maybe AtomLink -> Maybe FeedPiece)
-> ConduitT Event FeedPiece m (Maybe AtomLink)
-> ConduitT Event FeedPiece m (Maybe FeedPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event FeedPiece m (Maybe AtomLink)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomLink)
atomLink
          , (AtomURI -> FeedPiece) -> Maybe AtomURI -> Maybe FeedPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomURI -> FeedPiece
FeedLogo (Maybe AtomURI -> Maybe FeedPiece)
-> ConduitT Event FeedPiece m (Maybe AtomURI)
-> ConduitT Event FeedPiece m (Maybe FeedPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ConduitT Event FeedPiece m (Maybe AtomURI)
forall (m :: * -> *) o.
MonadThrow m =>
ConduitM Event o m (Maybe AtomURI)
atomLogo
          , (AtomText -> FeedPiece) -> Maybe AtomText -> Maybe FeedPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomText -> FeedPiece
FeedRights (Maybe AtomText -> Maybe FeedPiece)
-> ConduitT Event FeedPiece m (Maybe AtomText)
-> ConduitT Event FeedPiece m (Maybe FeedPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event FeedPiece m (Maybe AtomText)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe AtomText)
atomText Text
"rights"
          , (AtomText -> FeedPiece) -> Maybe AtomText -> Maybe FeedPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomText -> FeedPiece
FeedSubtitle (Maybe AtomText -> Maybe FeedPiece)
-> ConduitT Event FeedPiece m (Maybe AtomText)
-> ConduitT Event FeedPiece m (Maybe FeedPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event FeedPiece m (Maybe AtomText)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe AtomText)
atomText Text
"subtitle"
          , (AtomText -> FeedPiece) -> Maybe AtomText -> Maybe FeedPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AtomText -> FeedPiece
FeedTitle (Maybe AtomText -> Maybe FeedPiece)
-> ConduitT Event FeedPiece m (Maybe AtomText)
-> ConduitT Event FeedPiece m (Maybe FeedPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event FeedPiece m (Maybe AtomText)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe AtomText)
atomText Text
"title"
          , (UTCTime -> FeedPiece) -> Maybe UTCTime -> Maybe FeedPiece
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap UTCTime -> FeedPiece
FeedUpdated (Maybe UTCTime -> Maybe FeedPiece)
-> ConduitT Event FeedPiece m (Maybe UTCTime)
-> ConduitT Event FeedPiece m (Maybe FeedPiece)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ConduitT Event FeedPiece m (Maybe UTCTime)
forall (m :: * -> *) o.
MonadThrow m =>
Text -> ConduitM Event o m (Maybe UTCTime)
tagDate Text
"updated"
          ]