    --------------------------------------------------------------------
    -- |
    -- Module    : Text.Feed.Export
    -- Copyright : (c) Galois, Inc. 2008,
    --             (c) Sigbjorn Finne 2009-
    -- License   : BSD3
    --
    -- Maintainer: Sigbjorn Finne <sof@forkIO.com>
    -- Stability : provisional
    --
    -- Convert from Feeds to XML.
    --
    --------------------------------------------------------------------
    module Text.Feed.Export
      ( Text.Feed.Export.xmlFeed -- :: Feed -> XML.Element
      , Text.Feed.Export.textFeed -- :: Feed -> TL.Text
      , Text.Feed.Export.textFeedWith
      ) where

    import Prelude.Compat

    import Text.Feed.Types

    import qualified Data.Text.Util as U
    import Text.Atom.Feed.Export as Atom
    import Text.RSS.Export as RSS
    import Text.RSS1.Export as RSS1

    import qualified Data.Text.Lazy as TL
    import Data.XML.Types as XML
    import Text.XML (RenderSettings)

    -- | 'xmlFeed f' serializes a @Feed@ document into a conforming
    -- XML toplevel element.
    xmlFeed :: Feed -> XML.Element
    xmlFeed :: Feed -> Element
    xmlFeed Feed
    fe =
      case Feed
    fe of
        AtomFeed Feed
    f -> Feed -> Element
    Atom.xmlFeed Feed
    f
        RSSFeed RSS
    f -> RSS -> Element
    RSS.xmlRSS RSS
    f
        RSS1Feed Feed
    f -> Feed -> Element
    RSS1.xmlFeed Feed
    f
        XMLFeed Element
    e -> Element
    e -- that was easy!

    textFeed :: Feed -> Maybe TL.Text
    textFeed :: Feed -> Maybe Text
    textFeed = (Feed -> Element) -> Feed -> Maybe Text
    forall a. (a -> Element) -> a -> Maybe Text
    U.renderFeed Feed -> Element
    Text.Feed.Export.xmlFeed

    textFeedWith :: RenderSettings -> Feed -> Maybe TL.Text
    textFeedWith :: RenderSettings -> Feed -> Maybe Text
    textFeedWith RenderSettings
    settings = RenderSettings -> (Feed -> Element) -> Feed -> Maybe Text
    forall a. RenderSettings -> (a -> Element) -> a -> Maybe Text
    U.renderFeedWith RenderSettings
    settings Feed -> Element
    Text.Feed.Export.xmlFeed