{-# LANGUAGE NoImplicitPrelude #-}

{-|
Module      : Headroom.Variables.Types
Description : Data types for "Headroom.Variables"
Copyright   : (c) 2019-2021 Vaclav Svejcar
License     : BSD-3-Clause
Maintainer  : vaclav.svejcar@gmail.com
Stability   : experimental
Portability : POSIX

This module contains data types for "Headroom.Variables" module.
-}

module Headroom.Variables.Types
  ( Variables(..)
  )
where

import           RIO

-- | Map of /static/ and /dynamic variables/. Use 'Headroom.Variables.mkVariables' function for
-- more convenient construction of this data type.
newtype Variables = Variables (HashMap Text Text) deriving (Variables -> Variables -> Bool
(Variables -> Variables -> Bool)
-> (Variables -> Variables -> Bool) -> Eq Variables
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Variables -> Variables -> Bool
$c/= :: Variables -> Variables -> Bool
== :: Variables -> Variables -> Bool
$c== :: Variables -> Variables -> Bool
Eq, Int -> Variables -> ShowS
[Variables] -> ShowS
Variables -> String
(Int -> Variables -> ShowS)
-> (Variables -> String)
-> ([Variables] -> ShowS)
-> Show Variables
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Variables] -> ShowS
$cshowList :: [Variables] -> ShowS
show :: Variables -> String
$cshow :: Variables -> String
showsPrec :: Int -> Variables -> ShowS
$cshowsPrec :: Int -> Variables -> ShowS
Show)

instance Semigroup Variables where
  (Variables HashMap Text Text
x) <> :: Variables -> Variables -> Variables
<> (Variables HashMap Text Text
y) = HashMap Text Text -> Variables
Variables (HashMap Text Text
y HashMap Text Text -> HashMap Text Text -> HashMap Text Text
forall a. Semigroup a => a -> a -> a
<> HashMap Text Text
x)

instance Monoid Variables where
  mempty :: Variables
mempty = HashMap Text Text -> Variables
Variables HashMap Text Text
forall a. Monoid a => a
mempty