-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Basic Atom feed construction -- @package atom-basic @version 0.2.3 -- | atom-basic lets you generate Atom Feeds and Atom Entries. It -- provides the Feed and Entry types for the respective -- Atom document. This module is intended to be imported qualified to -- avoid name clashes: -- --
-- import qualified Web.Atom as Atom ---- -- XML generation is not built in because there are several Haskell XML -- libraries that you might want to use depending on your circumstances. -- To allow for this, you need to provide an XMLGen record to the -- feedXML or entryXML functions. An XMLGen record -- contains functions that generate XML of the type you prefer. Thanks -- to Ollie Charles for this suggestion. -- -- A minimal, but complete example using the xml package, looks -- like this (GitHub): -- --
-- {-# LANGUAGE OverloadedStrings #-}
--
-- import qualified Data.Text as T
-- import Data.Time (UTCTime (..), fromGregorian)
-- import Text.XML.Light
-- import qualified Web.Atom as Atom
--
-- feed :: Atom.Feed Element
-- feed = Atom.makeFeed
-- (Atom.unsafeURI "https://haskell.org/")
-- (Atom.TextHTML "The <em>Title</em>")
-- (UTCTime (fromGregorian 2015 7 8) 0)
--
-- xmlgen :: Atom.XMLGen Element Content QName Attr
-- xmlgen = Atom.XMLGen
-- { Atom.xmlElem = \n as ns -> Element n as ns Nothing
-- , Atom.xmlName = \nsMay name -> QName (T.unpack name)
-- (fmap T.unpack nsMay) Nothing
-- , Atom.xmlAttr = \k v -> Attr k (T.unpack v)
-- , Atom.xmlTextNode = \t -> Text $ CData CDataText (T.unpack t) Nothing
-- , Atom.xmlElemNode = Elem
-- }
--
-- main = putStr $ ppTopElement $ Atom.feedXML xmlgen feed
--
--
-- Another example that uses the xml-conduit package instead is
-- also available in the GitHub repository.
module Web.Atom
-- | Convenience constructor with defaults for all non-required fields.
makeFeed :: URI -> Text e -> UTCTime -> Feed e
-- | Convenience constructor with defaults for all non-required fields.
makeEntry :: URI -> Text e -> UTCTime -> Entry e
-- | Generate an XML value from a Feed.
feedXML :: XMLGen e node name attr -> Feed e -> e
-- | Generate an XML value from an Entry.
entryXML :: XMLGen e node name attr -> Entry e -> e
-- | This record defines what kind of XML we should construct. A valid
-- definition of this record must be provided to the feedXML and
-- entryXML functions. This lets users use the XML library of
-- their choice for the Atom feed XML. A couple of concrete examples are
-- provided at the top of this page. Here's an example that uses the
-- xml-conduit package:
--
--
-- xmlgen :: Atom.XMLGen Element Node Name (Name, T.Text)
-- xmlgen = Atom.XMLGen
-- { Atom.xmlElem = \n as ns -> Element n (fromList as) ns
-- , Atom.xmlName = \nsMay name -> Name name nsMay Nothing
-- , Atom.xmlAttr = \k v -> (k, v)
-- , Atom.xmlTextNode = NodeContent
-- , Atom.xmlElemNode = NodeElement
-- }
--
data XMLGen elem node name attr
XMLGen :: (name -> [attr] -> [node] -> elem) -> (Maybe Text -> Text -> name) -> (name -> Text -> attr) -> (Text -> node) -> (elem -> node) -> XMLGen elem node name attr
-- | Create element from name, attributes, and nodes/contents.
xmlElem :: XMLGen elem node name attr -> name -> [attr] -> [node] -> elem
-- | Create qualified name from optional namespace and name.
xmlName :: XMLGen elem node name attr -> Maybe Text -> Text -> name
-- | Create attribute from qualified name and text value.
xmlAttr :: XMLGen elem node name attr -> name -> Text -> attr
-- | Create text node/content from text value.
xmlTextNode :: XMLGen elem node name attr -> Text -> node
-- | Create element node/content from element.
xmlElemNode :: XMLGen elem node name attr -> elem -> node
-- | Top-level element for an Atom Feed Document as per
-- https://tools.ietf.org/html/rfc4287#section-4.1.1.
data Feed e
Feed :: URI -> Text e -> UTCTime -> Maybe (Text e) -> Maybe URI -> Maybe URI -> Maybe (Text e) -> Maybe Generator -> [Person] -> [Person] -> [Category] -> [Link] -> [Entry e] -> Feed e
feedId :: Feed e -> URI
feedTitle :: Feed e -> Text e
feedUpdated :: Feed e -> UTCTime
feedSubtitle :: Feed e -> Maybe (Text e)
feedIcon :: Feed e -> Maybe URI
feedLogo :: Feed e -> Maybe URI
feedRights :: Feed e -> Maybe (Text e)
feedGenerator :: Feed e -> Maybe Generator
feedAuthors :: Feed e -> [Person]
feedContributors :: Feed e -> [Person]
feedCategories :: Feed e -> [Category]
feedLinks :: Feed e -> [Link]
feedEntries :: Feed e -> [Entry e]
-- | An individual Atom entry that can be used either as a child of
-- Feed or as the top-level element of a stand-alone Atom Entry
-- Document as per
-- https://tools.ietf.org/html/rfc4287#section-4.1.2.
data Entry e
Entry :: URI -> (Text e) -> UTCTime -> Maybe UTCTime -> Maybe (Text e) -> Maybe (Content e) -> Maybe (Text e) -> Maybe (Source e) -> [Person] -> [Person] -> [Category] -> [Link] -> Entry e
entryId :: Entry e -> URI
entryTitle :: Entry e -> (Text e)
entryUpdated :: Entry e -> UTCTime
entryPublished :: Entry e -> Maybe UTCTime
entrySummary :: Entry e -> Maybe (Text e)
entryContent :: Entry e -> Maybe (Content e)
entryRights :: Entry e -> Maybe (Text e)
entrySource :: Entry e -> Maybe (Source e)
entryAuthors :: Entry e -> [Person]
entryContributors :: Entry e -> [Person]
entryCategories :: Entry e -> [Category]
entryLinks :: Entry e -> [Link]
-- | If an Atom entry is copied into a different feed, Source can be
-- used to preserve the metadata of the original feed as per
-- https://tools.ietf.org/html/rfc4287#section-4.2.11.
data Source e
Source :: Maybe URI -> Maybe (Text e) -> Maybe UTCTime -> Maybe (Text e) -> Maybe URI -> Maybe URI -> Maybe (Text e) -> Maybe Generator -> [Person] -> [Person] -> [Category] -> [Link] -> Source e
sourceId :: Source e -> Maybe URI
sourceTitle :: Source e -> Maybe (Text e)
sourceUpdated :: Source e -> Maybe UTCTime
sourceSubtitle :: Source e -> Maybe (Text e)
sourceIcon :: Source e -> Maybe URI
sourceLogo :: Source e -> Maybe URI
sourceRights :: Source e -> Maybe (Text e)
sourceGenerator :: Source e -> Maybe Generator
sourceAuthors :: Source e -> [Person]
sourceContributors :: Source e -> [Person]
sourceCategories :: Source e -> [Category]
sourceLinks :: Source e -> [Link]
-- | Content or link to content of an Atom entry as per
-- https://tools.ietf.org/html/rfc4287#section-4.1.3.
data Content e
InlinePlainContent :: Text -> Content e
InlineHTMLContent :: Text -> Content e
InlineXHTMLContent :: e -> Content e
InlineXMLContent :: e -> (Maybe MediaType) -> Content e
InlineTextContent :: Text -> (Maybe MediaType) -> Content e
InlineBase64Content :: ByteString -> (Maybe MediaType) -> Content e
OutOfLineContent :: URI -> (Maybe MediaType) -> Content e
-- | Information about a feed or entry category as per
-- https://tools.ietf.org/html/rfc4287#section-4.2.2.
data Category
Category :: Text -> Maybe URI -> Maybe Text -> Category
categoryTerm :: Category -> Text
categoryScheme :: Category -> Maybe URI
categoryLabel :: Category -> Maybe Text
-- | Identifies the agent used to generate the feed, for debugging and
-- other purposes as per
-- https://tools.ietf.org/html/rfc4287#section-4.2.4.
data Generator
Generator :: Text -> Maybe URI -> Maybe Text -> Generator
generatorName :: Generator -> Text
generatorURI :: Generator -> Maybe URI
version :: Generator -> Maybe Text
-- | Describes a person as per
-- https://tools.ietf.org/html/rfc4287#section-3.2.
data Person
Person :: Text -> Maybe URI -> Maybe Email -> Person
personName :: Person -> Text
personURI :: Person -> Maybe URI
personEmail :: Person -> Maybe Email
-- | An email address. xsd:string { pattern = ".+.+" }@
data Email
Email :: Text -> Email
-- | rel attribute for link elements as per
-- https://tools.ietf.org/html/rfc4287#section-4.2.7.2.
data Rel
RelText :: Text -> Rel
RelURI :: URI -> Rel
-- | Human readable text as per
-- https://tools.ietf.org/html/rfc4287#section-3.1.
data Text e
TextPlain :: Text -> Text e
TextHTML :: Text -> Text e
TextXHTML :: e -> Text e
-- | Defines a reference to a web resource as per
-- https://tools.ietf.org/html/rfc4287#section-4.2.7.
data Link
Link :: URI -> Maybe Rel -> Maybe MediaType -> Maybe LanguageTag -> Maybe Text -> Maybe Integer -> Link
linkHref :: Link -> URI
linkRel :: Link -> Maybe Rel
linkType :: Link -> Maybe MediaType
linkHrefLang :: Link -> Maybe LanguageTag
linkTitle :: Link -> Maybe Text
linkLength :: Link -> Maybe Integer
-- | Langauge tag as per https://tools.ietf.org/html/rfc3066.
data LanguageTag
LanguageTag :: Text -> LanguageTag
-- | A media type. xsd:string { pattern = ".+/.+" }
data MediaType
MediaType :: ByteString -> MediaType
-- | This is the simplest representation of UTC. It consists of the day
-- number, and a time offset from midnight. Note that if a day has a leap
-- second added to it, it will have 86401 seconds.
data UTCTime :: *
-- | Convenience function to create a URIs from hardcoded strings. /This
-- function is partial so only use this if you're hardcoding the URI
-- string and you're sure that it's valid./
unsafeURI :: String -> URI
-- | Represents a general universal resource identifier using its component
-- parts.
--
-- For example, for the URI
--
-- -- foo://anonymous@www.haskell.org:42/ghc?query#frag ---- -- the components are: data URI :: * URI :: String -> Maybe URIAuth -> String -> String -> String -> URI -- |
-- foo: --uriScheme :: URI -> String -- |
-- //anonymous@www.haskell.org:42 --uriAuthority :: URI -> Maybe URIAuth -- |
-- /ghc --uriPath :: URI -> String -- |
-- ?query --uriQuery :: URI -> String -- |
-- #frag --uriFragment :: URI -> String instance Show LanguageTag instance Eq LanguageTag instance Show Email instance Eq Email instance Show MediaType instance Eq MediaType instance Eq Rel instance Show e => Show (Text e) instance Eq e => Eq (Text e) instance Show e => Show (Content e) instance Eq e => Eq (Content e) instance Show Person instance Eq Person instance Show Generator instance Eq Generator instance Show Category instance Eq Category instance Show Link instance Eq Link instance Show e => Show (Source e) instance Eq e => Eq (Source e) instance Show e => Show (Entry e) instance Eq e => Eq (Entry e) instance Show e => Show (Feed e) instance Eq e => Eq (Feed e) instance ToXML e UTCTime instance ToXML e URI instance ToXML e Link instance ToXML e Generator instance ToXML e Category instance ToXML e Person instance ToXML e (Content e) instance ToXML e (Text e) instance ToXML e (Source e) instance ToXML e (Entry e) instance ToXML e (Feed e) instance IsString (Text e) instance IsString MediaType instance Show Rel