module Network.JSONApi.Link
( Links
, Rel
, Href
, mkLinks
) where
import Control.DeepSeq (NFData)
import Data.Aeson (ToJSON, FromJSON)
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Text (Text)
import qualified GHC.Generics as G
newtype Links = Links (Map Rel Href)
deriving (Show, Eq, Ord, ToJSON, FromJSON, G.Generic)
instance NFData Links
type Rel = Text
type Href = Text
mkLinks :: [(Rel, Text)] -> Links
mkLinks = Links . Map.fromList . map buildLink
buildLink :: (Rel, Text) -> (Rel, Href)
buildLink (key, url) = (key, url)