diff options
| author | Chris Wells <chris@mathematicaster.org> | 2025-01-31 13:19:33 -0600 |
|---|---|---|
| committer | Chris Wells <chris@mathematicaster.org> | 2025-01-31 13:19:33 -0600 |
| commit | c9e6d0ebabecf04e8f091234d293a85afe712057 (patch) | |
| tree | 0d657931c32488e4ee04cb1a20352f697a5e7a52 /src/Data/Person.hs | |
| parent | ca1d4d3d4371c8175ea6addb1ca1b09c3b56a7bb (diff) | |
| download | main-c9e6d0ebabecf04e8f091234d293a85afe712057.tar main-c9e6d0ebabecf04e8f091234d293a85afe712057.tar.gz main-c9e6d0ebabecf04e8f091234d293a85afe712057.tar.bz2 main-c9e6d0ebabecf04e8f091234d293a85afe712057.tar.lz main-c9e6d0ebabecf04e8f091234d293a85afe712057.tar.xz main-c9e6d0ebabecf04e8f091234d293a85afe712057.tar.zst main-c9e6d0ebabecf04e8f091234d293a85afe712057.zip | |
Adding more functionality
Diffstat (limited to 'src/Data/Person.hs')
| -rw-r--r-- | src/Data/Person.hs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Data/Person.hs b/src/Data/Person.hs new file mode 100644 index 0000000..a649c07 --- /dev/null +++ b/src/Data/Person.hs @@ -0,0 +1,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] |
