module Stitch.Types
( Selector(..)
, Children(..)
, Property(..)
, Import(..)
, Block(..)
, InnerBlock(..) ) where
import Stitch.Types.Selector
import Data.Map (Map)
import Data.Text (Text)
import Data.Semigroup (Semigroup(..))
import qualified Data.Map as Map
newtype Children = Children (Map Selector InnerBlock)
deriving (Show, Read, Eq)
instance Semigroup Children where
Children x <> Children y =
Children (Map.unionWith mappend x y)
instance Monoid Children where
mempty = Children mempty
mappend = (<>)
data Property = Property Text Text
| Comment Text
deriving (Show, Read, Eq)
newtype Import = Import Text
deriving (Show, Read, Eq)
data InnerBlock = InnerBlock [Property] Children
deriving (Show, Read, Eq)
instance Semigroup InnerBlock where
InnerBlock p c <> InnerBlock q d =
InnerBlock (p <> q) (c <> d)
instance Monoid InnerBlock where
mempty = InnerBlock [] mempty
mappend = (<>)
data Block = Block [Import] [Property] Children
deriving (Show, Read, Eq)
instance Semigroup Block where
Block i p c <> Block j q d =
Block (i <> j) (p <> q) (c <> d)
instance Monoid Block where
mempty = Block mempty mempty mempty
mappend = (<>)