--------------------------------------------------------------------
-- |
-- Module    : Text.Feed.Types
-- Copyright : (c) Galois, Inc. 2008,
--             (c) Sigbjorn Finne 2009-
-- License   : BSD3
--
-- Maintainer: Sigbjorn Finne <sof@forkIO.com>
-- Stability : provisional
-- Portability: portable
--
--------------------------------------------------------------------
module Text.Feed.Types
  ( Feed(..)
  , Item(..)
  , FeedKind(..)
  ) where

import Prelude.Compat

import Data.Text

import qualified Data.XML.Types as XML
import qualified Text.Atom.Feed as Atom
import qualified Text.RSS.Syntax as RSS
import qualified Text.RSS1.Syntax as RSS1

-- | The abstract type of feed documents. The internal representation
-- is as whatever feed variant type the document was either imported or
-- has now been translated to.
data Feed
  = AtomFeed Atom.Feed
  | RSSFeed RSS.RSS
  | RSS1Feed RSS1.Feed
    -- if we're unable to correctly the well-formed XML as a feed,
    -- keep it as an untyped document.
  | XMLFeed XML.Element
  deriving (Int -> Feed -> ShowS
[Feed] -> ShowS
Feed -> String
(Int -> Feed -> ShowS)
-> (Feed -> String) -> ([Feed] -> ShowS) -> Show Feed
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Feed] -> ShowS
$cshowList :: [Feed] -> ShowS
show :: Feed -> String
$cshow :: Feed -> String
showsPrec :: Int -> Feed -> ShowS
$cshowsPrec :: Int -> Feed -> ShowS
Show)

-- | The abstract type of feed items. Like the 'Text.Feed.Types.Feed' type, the
-- representation of a value is as one of the different RSS item\/entry
-- variants.
data Item
  = AtomItem Atom.Entry
  | RSSItem RSS.RSSItem
  | RSS1Item RSS1.Item
  | XMLItem XML.Element
  deriving (Int -> Item -> ShowS
[Item] -> ShowS
Item -> String
(Int -> Item -> ShowS)
-> (Item -> String) -> ([Item] -> ShowS) -> Show Item
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Item] -> ShowS
$cshowList :: [Item] -> ShowS
show :: Item -> String
$cshow :: Item -> String
showsPrec :: Int -> Item -> ShowS
$cshowsPrec :: Int -> Item -> ShowS
Show)

-- | The kinds of feed documents supported.
data FeedKind
  = AtomKind
  | RSSKind (Maybe Text) -- Nothing => default version (2.0)
  | RDFKind (Maybe Text) -- Nothing => default version (1.0)
  deriving (FeedKind -> FeedKind -> Bool
(FeedKind -> FeedKind -> Bool)
-> (FeedKind -> FeedKind -> Bool) -> Eq FeedKind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FeedKind -> FeedKind -> Bool
$c/= :: FeedKind -> FeedKind -> Bool
== :: FeedKind -> FeedKind -> Bool
$c== :: FeedKind -> FeedKind -> Bool
Eq, Int -> FeedKind -> ShowS
[FeedKind] -> ShowS
FeedKind -> String
(Int -> FeedKind -> ShowS)
-> (FeedKind -> String) -> ([FeedKind] -> ShowS) -> Show FeedKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FeedKind] -> ShowS
$cshowList :: [FeedKind] -> ShowS
show :: FeedKind -> String
$cshow :: FeedKind -> String
showsPrec :: Int -> FeedKind -> ShowS
$cshowsPrec :: Int -> FeedKind -> ShowS
Show)