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

    import Prelude.Compat

    -- | Atom feeds uses typed IRI links to represent
    -- information \/ metadata that is of interest to the
    -- consumers (software, in the main) of feeds. For instance,
    -- the edit link relation attached to an atom:entry element
    -- points to the IRI to use to update\/edit it.
    --
    -- The Atom standard encourages that such typed links to
    -- be registered with IANA if they have wider applicability,
    -- and the 'LinkRelation' data type encodes the currently
    -- registered link types (derived from:
    --  http:\/\/www.iana.org\/assignments\/link-relations.html
    -- on 2007-10-28]
    --
    data LinkRelation -- relevant RFC:
      = LinkAlternate -- http://www.rfc-editor.org/rfc/rfc4287.txt
      | LinkCurrent -- http://www.rfc-editor.org/rfc/rfc5005.txt
      | LinkEnclosure -- http://www.rfc-editor.org/rfc/rfc4287.txt
      | LinkEdit -- http://www.rfc-editor.org/rfc/rfc5023.txt
      | LinkEditMedia -- http://www.rfc-editor.org/rfc/rfc5023.txt
      | LinkFirst -- http://www.iana.org/assignments/link-relations/first
      | LinkLast -- http://www.iana.org/assignments/link-relations/last
      | LinkLicense -- http://www.rfc-editor.org/rfc/rfc4946.txt
      | LinkNext -- http://www.rfc-editor.org/rfc/rfc5005.txt
      | LinkNextArchive -- http://www.rfc-editor.org/rfc/rfc5005.txt
      | LinkPayment -- http://www.iana.org/assignments/link-relations/payment
      | LinkPrevArchive -- http://www.rfc-editor.org/rfc/rfc5005.txt
      | LinkPrevious -- http://www.rfc-editor.org/rfc/rfc5005.txt
      | LinkRelated -- http://www.rfc-editor.org/rfc/rfc4287.txt
      | LinkReplies -- http://www.rfc-editor.org/rfc/rfc4685.txt
      | LinkSelf -- http://www.rfc-editor.org/rfc/rfc4287.txt
      | LinkVia -- http://www.rfc-editor.org/rfc/rfc4287.txt
      | LinkOther String
      deriving (LinkRelation -> LinkRelation -> Bool
    (LinkRelation -> LinkRelation -> Bool)
    -> (LinkRelation -> LinkRelation -> Bool) -> Eq LinkRelation
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: LinkRelation -> LinkRelation -> Bool
    == :: LinkRelation -> LinkRelation -> Bool
    $c/= :: LinkRelation -> LinkRelation -> Bool
    /= :: LinkRelation -> LinkRelation -> Bool
    Eq, Int -> LinkRelation -> ShowS
    [LinkRelation] -> ShowS
    LinkRelation -> [Char]
    (Int -> LinkRelation -> ShowS)
    -> (LinkRelation -> [Char])
    -> ([LinkRelation] -> ShowS)
    -> Show LinkRelation
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> LinkRelation -> ShowS
    showsPrec :: Int -> LinkRelation -> ShowS
    $cshow :: LinkRelation -> [Char]
    show :: LinkRelation -> [Char]
    $cshowList :: [LinkRelation] -> ShowS
    showList :: [LinkRelation] -> ShowS
    Show)

    showLinkRelation :: LinkRelation -> String
    showLinkRelation :: LinkRelation -> [Char]
    showLinkRelation LinkRelation
    lr =
      case LinkRelation
    lr of
        LinkRelation
    LinkAlternate -> [Char]
    "alternate"
        LinkRelation
    LinkCurrent -> [Char]
    "current"
        LinkRelation
    LinkEnclosure -> [Char]
    "enclosure"
        LinkRelation
    LinkEdit -> [Char]
    "edit"
        LinkRelation
    LinkEditMedia -> [Char]
    "edit-media"
        LinkRelation
    LinkFirst -> [Char]
    "first"
        LinkRelation
    LinkLast -> [Char]
    "last"
        LinkRelation
    LinkLicense -> [Char]
    "license"
        LinkRelation
    LinkNext -> [Char]
    "next"
        LinkRelation
    LinkNextArchive -> [Char]
    "next-archive"
        LinkRelation
    LinkPayment -> [Char]
    "payment"
        LinkRelation
    LinkPrevArchive -> [Char]
    "prev-archive"
        LinkRelation
    LinkPrevious -> [Char]
    "previous"
        LinkRelation
    LinkRelated -> [Char]
    "related"
        LinkRelation
    LinkReplies -> [Char]
    "replies"
        LinkRelation
    LinkSelf -> [Char]
    "self"
        LinkRelation
    LinkVia -> [Char]
    "via"
        LinkOther [Char]
    s -> [Char]
    s

    showLinkAttr :: LinkRelation -> String -> String {-URI-}
    showLinkAttr :: LinkRelation -> ShowS
    showLinkAttr LinkRelation
    lr [Char]
    s = LinkRelation -> [Char]
    showLinkRelation LinkRelation
    lr [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Char
    '=' Char -> ShowS
    forall a. a -> [a] -> [a]
    : Char
    '"' Char -> ShowS
    forall a. a -> [a] -> [a]
    : (Char -> [Char]) -> ShowS
    forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
    concatMap Char -> [Char]
    escQ [Char]
    s [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "\""
      where
        escQ :: Char -> [Char]
    escQ Char
    '"' = [Char]
    "&dquot;"
        escQ Char
    x = [Char
    x]