feed 0.3.1 → 0.3.2
raw patch · 18 files changed
+203/−134 lines, 18 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.Atom.Feed: instance Eq Generator
+ Text.Atom.Feed: instance Show Category
+ Text.Atom.Feed: instance Show Entry
+ Text.Atom.Feed: instance Show EntryContent
+ Text.Atom.Feed: instance Show Feed
+ Text.Atom.Feed: instance Show Generator
+ Text.Atom.Feed: instance Show InReplyTo
+ Text.Atom.Feed: instance Show InReplyTotal
+ Text.Atom.Feed: instance Show Link
+ Text.Atom.Feed: instance Show Person
+ Text.Atom.Feed: instance Show Source
+ Text.Atom.Feed: instance Show TextContent
+ Text.Atom.Feed.Link: instance Eq LinkRelation
+ Text.Atom.Feed.Link: instance Show LinkRelation
+ Text.Atom.Feed.Validate: instance (Eq a) => Eq (VTree a)
+ Text.Atom.Feed.Validate: instance (Show a) => Show (VTree a)
+ Text.Atom.Pub: instance Show Categories
+ Text.DublinCore.Types: instance Eq DCItem
+ Text.DublinCore.Types: instance Show DCInfo
+ Text.DublinCore.Types: instance Show DCItem
+ Text.Feed.Types: instance Show Feed
+ Text.Feed.Types: instance Show FeedKind
+ Text.Feed.Types: instance Show Item
+ Text.RSS.Syntax: instance Show RSS
+ Text.RSS.Syntax: instance Show RSSCategory
+ Text.RSS.Syntax: instance Show RSSChannel
+ Text.RSS.Syntax: instance Show RSSCloud
+ Text.RSS.Syntax: instance Show RSSEnclosure
+ Text.RSS.Syntax: instance Show RSSGuid
+ Text.RSS.Syntax: instance Show RSSImage
+ Text.RSS.Syntax: instance Show RSSItem
+ Text.RSS.Syntax: instance Show RSSSource
+ Text.RSS.Syntax: instance Show RSSTextInput
+ Text.RSS1.Syntax: instance Eq ContentInfo
+ Text.RSS1.Syntax: instance Eq UpdatePeriod
+ Text.RSS1.Syntax: instance Show Channel
+ Text.RSS1.Syntax: instance Show ContentInfo
+ Text.RSS1.Syntax: instance Show Feed
+ Text.RSS1.Syntax: instance Show Image
+ Text.RSS1.Syntax: instance Show Item
+ Text.RSS1.Syntax: instance Show TaxonomyTopic
+ Text.RSS1.Syntax: instance Show TextInputInfo
+ Text.RSS1.Syntax: instance Show UpdatePeriod
Files
- Text/Atom/Feed.hs +115/−90
- Text/Atom/Feed/Export.hs +1/−1
- Text/Atom/Feed/Import.hs +1/−1
- Text/Atom/Feed/Link.hs +1/−0
- Text/Atom/Feed/Validate.hs +6/−5
- Text/Atom/Pub.hs +1/−0
- Text/Atom/Pub/Export.hs +1/−3
- Text/DublinCore/Types.hs +3/−6
- Text/Feed/Constructor.hs +1/−1
- Text/Feed/Export.hs +1/−1
- Text/Feed/Import.hs +1/−1
- Text/Feed/Types.hs +5/−3
- Text/RSS/Export.hs +1/−1
- Text/RSS/Import.hs +1/−1
- Text/RSS/Syntax.hs +52/−18
- Text/RSS1/Import.hs +2/−0
- Text/RSS1/Syntax.hs +8/−0
- feed.cabal +2/−2
Text/Atom/Feed.hs view
@@ -4,7 +4,7 @@ -- Copyright : (c) Galois, Inc. 2008 -- License : BSD3 ----- Maintainer: Don Stewart <dons@galois.com>+-- Maintainer: Isaac Potoczny-Jones <ijones@syntaxpolice.org> -- Stability : provisional -- Portability: --@@ -14,6 +14,8 @@ import qualified Text.XML.Light as XML +-- *Core types+ -- NOTE: In the future we may want to have more structured -- types for these. type URI = String@@ -39,25 +41,7 @@ , feedAttrs :: [XML.Attr] , feedOther :: [XML.Element] }--nullFeed :: String -> TextContent -> Date -> Feed-nullFeed i t u = Feed- { feedId = i- , feedTitle = t- , feedUpdated = u- , feedAuthors = []- , feedCategories = []- , feedContributors = []- , feedGenerator = Nothing- , feedIcon = Nothing- , feedLinks = []- , feedLogo = Nothing- , feedRights = Nothing- , feedSubtitle = Nothing- , feedEntries = []- , feedAttrs = []- , feedOther = []- }+ deriving (Show) data Entry = Entry@@ -78,26 +62,7 @@ , entryAttrs :: [XML.Attr] , entryOther :: [XML.Element] }--nullEntry :: String -> TextContent -> Date -> Entry-nullEntry i t u = Entry- { entryId = i- , entryTitle = t- , entryUpdated = u- , entryAuthors = []- , entryCategories = []- , entryContent = Nothing- , entryContributor = []- , entryLinks = []- , entryPublished = Nothing- , entryRights = Nothing- , entrySource = Nothing- , entrySummary = Nothing- , entryInReplyTo = Nothing- , entryInReplyTotal = Nothing- , entryAttrs = []- , entryOther = []- }+ deriving (Show) data EntryContent = TextContent String@@ -105,6 +70,7 @@ | XHTMLContent XML.Element | MixedContent (Maybe String) [XML.Content] | ExternalContent (Maybe MediaType) URI+ deriving (Show) data Category = Category@@ -113,14 +79,8 @@ , catLabel :: Maybe String -- ^ human-readable label of the category , catOther :: [XML.Element] -- ^ unknown elements, for extensibility. }+ deriving (Show) -newCategory :: String -> Category-newCategory t = Category- { catTerm = t- , catScheme = Nothing- , catLabel = Just t- , catOther = []- } data Generator = Generator@@ -128,14 +88,7 @@ , genVersion :: Maybe String , genText :: String }--nullGenerator :: String -> Generator-nullGenerator t = Generator- { genURI = Nothing- , genVersion = Nothing- , genText = t- }-+ deriving (Eq, Show) data Link = Link@@ -148,22 +101,13 @@ , linkLength :: Maybe String , linkOther :: [XML.Element] }--nullLink :: URI -> Link-nullLink uri = Link- { linkHref = uri- , linkRel = Nothing- , linkType = Nothing- , linkHrefLang = Nothing- , linkTitle = Nothing- , linkLength = Nothing- , linkOther = []- }+ deriving (Show) data TextContent = TextString String | HTMLString String | XHTMLString XML.Element+ deriving (Show) data Source = Source@@ -180,23 +124,8 @@ , sourceUpdated :: Maybe Date , sourceOther :: [XML.Element] }+ deriving (Show) -nullSource :: Source-nullSource = Source- { sourceAuthors = []- , sourceCategories = []- , sourceGenerator = Nothing- , sourceIcon = Nothing- , sourceId = Nothing- , sourceLinks = []- , sourceLogo = Nothing- , sourceRights = Nothing- , sourceSubtitle = Nothing- , sourceTitle = Nothing- , sourceUpdated = Nothing- , sourceOther = []- }- data Person = Person@@ -205,14 +134,7 @@ , personEmail :: Maybe String , personOther :: [XML.Element] }--nullPerson :: Person-nullPerson = Person- { personName = ""- , personURI = Nothing- , personEmail = Nothing- , personOther = []- }+ deriving (Show) data InReplyTo = InReplyTo@@ -223,9 +145,112 @@ , replyToOther :: [XML.Attr] , replyToContent :: [XML.Content] }+ deriving (Show) data InReplyTotal = InReplyTotal { replyToTotal :: Integer -- non-negative :) , replyToTotalOther :: [XML.Attr] }+ deriving (Show)++-- *Smart Constructors++newCategory :: String -- ^catTerm+ -> Category+newCategory t = Category+ { catTerm = t+ , catScheme = Nothing+ , catLabel = Just t+ , catOther = []+ }++nullFeed :: String -- ^feedId+ -> TextContent -- ^feedTitle+ -> Date -- ^feedUpdated+ -> Feed+nullFeed i t u = Feed+ { feedId = i+ , feedTitle = t+ , feedUpdated = u+ , feedAuthors = []+ , feedCategories = []+ , feedContributors = []+ , feedGenerator = Nothing+ , feedIcon = Nothing+ , feedLinks = []+ , feedLogo = Nothing+ , feedRights = Nothing+ , feedSubtitle = Nothing+ , feedEntries = []+ , feedAttrs = []+ , feedOther = []+ }++nullEntry :: String -- ^entryId+ -> TextContent -- ^entryTitle+ -> Date -- ^entryUpdated+ -> Entry+nullEntry i t u = Entry+ { entryId = i+ , entryTitle = t+ , entryUpdated = u+ , entryAuthors = []+ , entryCategories = []+ , entryContent = Nothing+ , entryContributor = []+ , entryLinks = []+ , entryPublished = Nothing+ , entryRights = Nothing+ , entrySource = Nothing+ , entrySummary = Nothing+ , entryInReplyTo = Nothing+ , entryInReplyTotal = Nothing+ , entryAttrs = []+ , entryOther = []+ }+++nullGenerator :: String -- ^genText+ -> Generator+nullGenerator t = Generator+ { genURI = Nothing+ , genVersion = Nothing+ , genText = t+ }++nullLink :: URI -- ^linkHref+ -> Link+nullLink uri = Link+ { linkHref = uri+ , linkRel = Nothing+ , linkType = Nothing+ , linkHrefLang = Nothing+ , linkTitle = Nothing+ , linkLength = Nothing+ , linkOther = []+ }++nullSource :: Source+nullSource = Source+ { sourceAuthors = []+ , sourceCategories = []+ , sourceGenerator = Nothing+ , sourceIcon = Nothing+ , sourceId = Nothing+ , sourceLinks = []+ , sourceLogo = Nothing+ , sourceRights = Nothing+ , sourceSubtitle = Nothing+ , sourceTitle = Nothing+ , sourceUpdated = Nothing+ , sourceOther = []+ }+ +nullPerson :: Person+nullPerson = Person+ { personName = ""+ , personURI = Nothing+ , personEmail = Nothing+ , personOther = []+ }
Text/Atom/Feed/Export.hs view
@@ -6,7 +6,7 @@ -- -- Maintainer: Don Stewart <dons@galois.com> -- Stability : provisional--- Portability:+-- Description: Convert from Atom to XML -- --------------------------------------------------------------------
Text/Atom/Feed/Import.hs view
@@ -6,7 +6,7 @@ -- -- Maintainer: Don Stewart <dons@galois.com> -- Stability : provisional--- Portability:+-- Description: Convert from XML to Atom -- --------------------------------------------------------------------
Text/Atom/Feed/Link.hs view
@@ -48,6 +48,7 @@ | LinkSelf -- http://www.rfc-editor.org/rfc/rfc4287.txt | LinkVia -- http://www.rfc-editor.org/rfc/rfc4287.txt | LinkOther String + deriving (Eq, Show) showLinkRelation :: LinkRelation -> String showLinkRelation lr =
Text/Atom/Feed/Validate.hs view
@@ -9,6 +9,7 @@ import Data.Maybe data VTree a = VNode [a] [VTree a] | VLeaf [a]+ deriving (Eq, Show) type ValidatorResult = VTree (Bool,String) @@ -161,15 +162,15 @@ , checkLabel e ] where- checkScheme e = - case pAttrs "scheme" e of+ checkScheme e' = + case pAttrs "scheme" e' of [] -> valid (_:xs) | null xs -> valid | otherwise -> demand ("Expected at most one 'scheme' attribute, found: " ++ show (1+length xs)) - checkLabel e =- case pAttrs "label" e of+ checkLabel e' =+ case pAttrs "label" e' of [] -> valid (_:xs) | null xs -> valid@@ -217,7 +218,7 @@ [_] -> case types of [] -> advice "It is advisable to provide a 'type' along with a 'src' attribute"- (t:_) -> valid+ (_:_) -> valid {- case parseMIMEType t of Just{} -> valid
Text/Atom/Pub.hs view
@@ -41,5 +41,6 @@ data Categories = CategoriesExternal URI | Categories (Maybe Bool) (Maybe URI) [Category]+ deriving (Show) newtype Accept = Accept { acceptType :: String }
Text/Atom/Pub/Export.hs view
@@ -6,9 +6,7 @@ -- -- Maintainer: Don Stewart <dons@galois.com> -- Stability : provisional--- Portability:------ Serializing APP types (as XML.)+-- Description: Serializing APP types (as XML.) -- -------------------------------------------------------------------- module Text.Atom.Pub.Export where
Text/DublinCore/Types.hs view
@@ -6,11 +6,7 @@ -- -- Maintainer: Don Stewart <dons@galois.com> -- Stability : provisional--- Portability:------------------------------------------------------------------------------ Representing the DublinCore metadata elements in Haskell. The Dublin+-- Description: Representing the DublinCore metadata elements in Haskell. The Dublin -- Core Metadata Element Set. See: <http://dublincore.org/> -- module Text.DublinCore.Types where@@ -21,6 +17,7 @@ { dcElt :: DCInfo , dcText :: String }+ deriving (Eq, Show) -- | The Dublin Core Metadata Element Set, all 15 of them (plus an extension constructor.) data DCInfo@@ -40,7 +37,7 @@ | DC_Coverage -- ^ The extent or scope of the content of the resource. | DC_Rights -- ^ Information about rights held in and over the resource. | DC_Other String -- ^ Other; data type extension mechanism.- deriving ( Eq )+ deriving (Eq, Show) infoToTag :: DCInfo -> String infoToTag i =
Text/Feed/Constructor.hs view
@@ -6,7 +6,7 @@ -- -- Maintainer: Don Stewart <dons@galois.com> -- Stability : provisional --- Portability: +-- Description: Module for an abstraction layer between different kinds of feeds. -- --------------------------------------------------------------------
Text/Feed/Export.hs view
@@ -6,7 +6,7 @@ -- -- Maintainer: Don Stewart <dons@galois.com> -- Stability : provisional--- Portability:+-- Description: Convert from Feeds to XML. -- --------------------------------------------------------------------
Text/Feed/Import.hs view
@@ -6,7 +6,7 @@ -- -- Maintainer: Don Stewart <dons@galois.com> -- Stability : provisional--- Portability:+-- Description: Convert from XML to Feeds. -- --------------------------------------------------------------------
Text/Feed/Types.hs view
@@ -27,7 +27,8 @@ -- if we're unable to correctly the well-formed XML as a feed, -- keep it as an untyped document. | XMLFeed XML.Element- + deriving (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.@@ -36,11 +37,12 @@ | RSSItem RSS.RSSItem | RSS1Item RSS1.Item | XMLItem XML.Element- + deriving (Show)+ -- | The kinds of feed documents supported. data FeedKind = AtomKind | RSSKind (Maybe String) -- Nothing => default version (2.0) | RDFKind (Maybe String) -- Nothing => default version (1.0)- deriving ( Eq )+ deriving (Eq, Show)
Text/RSS/Export.hs view
@@ -6,7 +6,7 @@ -- -- Maintainer: Don Stewart <dons@galois.com> -- Stability : provisional--- Portability:+-- Description: Convert from RSS to XML -- --------------------------------------------------------------------
Text/RSS/Import.hs view
@@ -6,7 +6,7 @@ -- -- Maintainer: Don Stewart <dons@galois.com> -- Stability : provisional--- Portability:+-- Description: Converting from XML to RSS -- --------------------------------------------------------------------
Text/RSS/Syntax.hs view
@@ -4,10 +4,12 @@ -- Copyright : (c) Galois, Inc. 2008 -- License : BSD3 ----- Maintainer: Don Stewart <dons@galois.com>+-- Maintainer: Isaac Potoczny-Jones <ijones@syntaxpolice.org> -- Stability : provisional--- Portability:---+-- Description: The basic syntax for putting together feeds. For instance,+-- to create a feed with a single item item:+-- (nullRSS \"rss title\" \"link\") {rssChannel=(nullChannel \"channel title\" \"link\") {rssItems=[(nullItem \"item title\")]}}+ -------------------------------------------------------------------- @@ -15,7 +17,9 @@ import Text.XML.Light as XML --- The Radio Userland version of RSS documents\/feeds.+-- * Core Types++-- ^The Radio Userland version of RSS documents\/feeds. -- (versions 0.9x, 2.x) data RSS = RSS@@ -24,6 +28,7 @@ , rssChannel :: RSSChannel , rssOther :: [XML.Element] }+ deriving (Show) type URLString = String type DateString = String@@ -38,8 +43,8 @@ , rssCopyright :: Maybe String , rssEditor :: Maybe String , rssWebMaster :: Maybe String- , rssPubDate :: Maybe DateString -- rfc 822 conforming.- , rssLastUpdate :: Maybe DateString+ , rssPubDate :: Maybe DateString -- ^ rfc 822 conforming.+ , rssLastUpdate :: Maybe DateString -- ^ rfc 822 conforming. , rssCategories :: [RSSCategory] , rssGenerator :: Maybe String , rssDocs :: Maybe URLString@@ -52,12 +57,13 @@ , rssSkipDays :: Maybe [String] , rssChannelOther :: [XML.Element] }+ deriving (Show) data RSSItem = RSSItem { rssItemTitle :: Maybe String , rssItemLink :: Maybe URLString- , rssItemDescription :: Maybe String -- if not present, the title is. (per spec, at least.)+ , rssItemDescription :: Maybe String -- ^if not present, the title is. (per spec, at least.) , rssItemAuthor :: Maybe String , rssItemCategories :: [RSSCategory] , rssItemComments :: Maybe URLString@@ -68,6 +74,7 @@ , rssItemAttrs :: [XML.Attr] , rssItemOther :: [XML.Element] }+ deriving (Show) data RSSSource = RSSSource@@ -75,6 +82,7 @@ , rssSourceAttrs :: [XML.Attr] , rssSourceTitle :: String }+ deriving (Show) data RSSEnclosure = RSSEnclosure@@ -83,6 +91,7 @@ , rssEnclosureType :: String , rssEnclosureAttrs :: [XML.Attr] }+ deriving (Show) data RSSCategory = RSSCategory@@ -90,6 +99,7 @@ , rssCategoryAttrs :: [XML.Attr] , rssCategoryValue :: String }+ deriving (Show) data RSSGuid = RSSGuid@@ -97,6 +107,7 @@ , rssGuidAttrs :: [XML.Attr] , rssGuidValue :: String }+ deriving (Show) data RSSImage@@ -109,6 +120,7 @@ , rssImageDesc :: Maybe String , rssImageOther :: [XML.Element] }+ deriving (Show) data RSSCloud = RSSCloud@@ -119,6 +131,7 @@ , rssCloudProtocol :: Maybe String , rssCloudAttrs :: [XML.Attr] }+ deriving (Show) data RSSTextInput = RSSTextInput@@ -129,9 +142,13 @@ , rssTextInputAttrs :: [XML.Attr] , rssTextInputOther :: [XML.Element] }+ deriving (Show) --- default constructors:-nullRSS :: String -> URLString -> RSS+-- * Default Constructors:++nullRSS :: String -- ^channel title+ -> URLString -- ^channel link+ -> RSS nullRSS title link = RSS { rssVersion = "2.0"@@ -140,7 +157,9 @@ , rssOther = [] } -nullChannel :: String -> URLString -> RSSChannel+nullChannel :: String -- ^rssTitle+ -> URLString -- ^rssLink+ -> RSSChannel nullChannel title link = RSSChannel { rssTitle = title@@ -166,7 +185,8 @@ , rssChannelOther = [] } -nullItem :: String -> RSSItem+nullItem :: String -- ^title+ -> RSSItem nullItem title = RSSItem { rssItemTitle = Just title@@ -183,7 +203,9 @@ , rssItemOther = [] } -nullSource :: URLString -> String -> RSSSource+nullSource :: URLString -- ^source URL+ -> String -- ^title+ -> RSSSource nullSource url title = RSSSource { rssSourceURL = url@@ -191,7 +213,10 @@ , rssSourceTitle = title } -nullEnclosure :: URLString -> Integer -> String -> RSSEnclosure+nullEnclosure :: URLString -- ^enclosure URL+ -> Integer -- ^enclosure length+ -> String -- ^enclosure type+ -> RSSEnclosure nullEnclosure url len ty = RSSEnclosure { rssEnclosureURL = url@@ -200,7 +225,8 @@ , rssEnclosureAttrs = [] } -newCategory :: String -> RSSCategory+newCategory :: String -- ^category Value+ -> RSSCategory newCategory nm = RSSCategory { rssCategoryDomain = Nothing@@ -208,7 +234,8 @@ , rssCategoryValue = nm } -nullGuid :: String -> RSSGuid+nullGuid :: String -- ^guid value+ -> RSSGuid nullGuid v = RSSGuid { rssGuidPermanentURL = Nothing@@ -216,10 +243,14 @@ , rssGuidValue = v } -nullPermaGuid :: String -> RSSGuid+nullPermaGuid :: String -- ^guid value+ -> RSSGuid nullPermaGuid v = (nullGuid v){rssGuidPermanentURL=Just True} -nullImage :: URLString -> String -> URLString -> RSSImage+nullImage :: URLString -- ^imageURL+ -> String -- ^imageTitle+ -> URLString -- ^imageLink+ -> RSSImage nullImage url title link = RSSImage { rssImageURL = url@@ -242,7 +273,10 @@ , rssCloudAttrs = [] } -nullTextInput :: String -> String -> URLString -> RSSTextInput+nullTextInput :: String -- ^inputTitle+ -> String -- ^inputName+ -> URLString -- ^inputLink+ -> RSSTextInput nullTextInput title nm link = RSSTextInput { rssTextInputTitle = title
Text/RSS1/Import.hs view
@@ -228,6 +228,7 @@ fmap strContent (pQNode (qualName (rdfNS,rdfPrefix) "li") e)) (fromMaybe [] $ fmap children $ pQNode (qualName (rdfNS,rdfPrefix) "Bag") be) +{- bagElements :: XML.Element -> [XML.Element] bagElements be = mapMaybe @@ -235,6 +236,7 @@ guard (elName e == rdfName "li") return e) (fromMaybe [] $ fmap children $ pQNode (rdfName "Bag") be)+-} seqLeaves :: XML.Element -> [URIString] seqLeaves se =
Text/RSS1/Syntax.hs view
@@ -30,6 +30,7 @@ , feedOther :: [XML.Element] , feedAttrs :: [XML.Attr] }+ deriving (Show) data Channel = Channel@@ -51,6 +52,7 @@ , channelOther :: [XML.Element] , channelAttrs :: [XML.Attr] }+ deriving (Show) data Image = Image@@ -62,6 +64,7 @@ , imageOther :: [XML.Element] , imageAttrs :: [XML.Attr] }+ deriving (Show) data Item = Item@@ -75,6 +78,7 @@ , itemOther :: [XML.Element] , itemAttrs :: [XML.Attr] }+ deriving (Show) data TextInputInfo = TextInputInfo@@ -87,6 +91,7 @@ , textInputOther :: [XML.Element] , textInputAttrs :: [XML.Attr] }+ deriving (Show) data TaxonomyTopic = TaxonomyTopic@@ -98,6 +103,7 @@ , taxonomyDC :: [DCItem] , taxonomyOther :: [XML.Element] }+ deriving (Show) data UpdatePeriod @@ -106,6 +112,7 @@ | Update_Weekly | Update_Monthly | Update_Yearly+ deriving (Eq, Show) data ContentInfo = ContentInfo@@ -114,6 +121,7 @@ , contentEncoding :: Maybe URIString , contentValue :: Maybe String -- should be: RDFValue }+ deriving (Eq, Show) --default constructors: nullFeed :: URIString -> TitleString -> Feed
feed.cabal view
@@ -1,5 +1,5 @@ Name: feed-Version: 0.3.1+Version: 0.3.2 License: BSD3 License-file: LICENSE Category: Text@@ -37,5 +37,5 @@ Text.Feed.Query Text.Feed.Constructor Text.Feed.Translate- Ghc-Options: -Wall -O2+ Ghc-Options: -Wall Build-Depends: base, xml >= 1.2.6