29 lines
683 B
Haskell
29 lines
683 B
Haskell
{-# LANGUAGE DeriveGeneric #-}
|
|
{-# LANGUAGE NamedFieldPuns #-}
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
module Blog.URL (
|
|
URL(..)
|
|
, build
|
|
) where
|
|
|
|
import Arguments (Arguments)
|
|
import qualified Arguments as Arguments (Arguments(..))
|
|
import Data.Aeson (ToJSON(..), (.=), pairs)
|
|
import GHC.Generics (Generic)
|
|
|
|
data URL = URL {
|
|
comments :: Maybe String
|
|
, site :: Maybe String
|
|
} deriving Generic
|
|
|
|
instance ToJSON URL where
|
|
toEncoding (URL {comments}) = pairs (
|
|
"comments" .= comments
|
|
)
|
|
|
|
build :: Arguments -> IO URL
|
|
build arguments = return $ URL {comments, site}
|
|
where
|
|
comments = Arguments.commentsURL arguments
|
|
site = Arguments.siteURL arguments
|