module Text.Atom.Feed.Link
( LinkRelation(..)
, showLinkRelation
, showLinkAttr
) where
import Prelude.Compat
data LinkRelation
= LinkAlternate
| LinkCurrent
| LinkEnclosure
| LinkEdit
| LinkEditMedia
| LinkFirst
| LinkLast
| LinkLicense
| LinkNext
| LinkNextArchive
| LinkPayment
| LinkPrevArchive
| LinkPrevious
| LinkRelated
| LinkReplies
| LinkSelf
| LinkVia
| LinkOther String
deriving (LinkRelation -> LinkRelation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LinkRelation -> LinkRelation -> Bool
$c/= :: LinkRelation -> LinkRelation -> Bool
== :: LinkRelation -> LinkRelation -> Bool
$c== :: LinkRelation -> LinkRelation -> Bool
Eq, Int -> LinkRelation -> ShowS
[LinkRelation] -> ShowS
LinkRelation -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [LinkRelation] -> ShowS
$cshowList :: [LinkRelation] -> ShowS
show :: LinkRelation -> [Char]
$cshow :: LinkRelation -> [Char]
showsPrec :: Int -> LinkRelation -> ShowS
$cshowsPrec :: Int -> 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
showLinkAttr :: LinkRelation -> ShowS
showLinkAttr LinkRelation
lr [Char]
s = LinkRelation -> [Char]
showLinkRelation LinkRelation
lr forall a. [a] -> [a] -> [a]
++ Char
'=' forall a. a -> [a] -> [a]
: Char
'"' forall a. a -> [a] -> [a]
: forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Char -> [Char]
escQ [Char]
s forall a. [a] -> [a] -> [a]
++ [Char]
"\""
where
escQ :: Char -> [Char]
escQ Char
'"' = [Char]
"&dquot;"
escQ Char
x = [Char
x]