blob: a649c07cf3ea0d13d64c2dbe1759d8cacf3b4d34 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
module Data.Person
( Person (..)
, personHtml
, personFromName
, Name (..)
, URI
) where
import Prolog
import Data.Name
import Network.URI (URI)
import Text.Blaze
import Text.Blaze.Html
import Text.Blaze.Html5 (a)
import Text.Blaze.Html5.Attributes (href)
data Person a = Person
{ name :: !(Name a)
, webpage :: !(Maybe URI)
, aliases :: ![Name a]
} deriving (Eq, Functor, Foldable, Generic, Ord, Show, Traversable)
instance Binary a => Binary (Person a)
personHtml :: (ToMarkup a) => Person a -> Html
personHtml (Person n w _) =
let withLink = maybe id (\x -> a ! href (toValue x)) w
in withLink $ renderNameFML $ toMarkup <$> n
personFromName :: Name a -> Person a
personFromName n = Person n Nothing [n]
|