module Text.HTML.Moe.Type where

import Data.Default
import Control.Monad.Writer
import Text.HTML.Moe.Utils
import Data.DList (DList)

data Element = 
    Element
      {
        name :: Internal
      , attributes :: [Attribute]
      , elements :: [Element]
      , indent :: Bool
      , self_close :: Bool
      }
  | Raw Internal  -- no escape, no indent
  | Pre Internal  -- escape, no indent
  | Data Internal -- escape, indent
  | Prim Internal -- no escape, indent
  deriving (Show)

instance Default Element where
  def = Element 
    {
      name = none
    , attributes = def
    , elements = def
    , indent = True
    , self_close = False
    }

data Attribute = Attribute
  {
    key :: Internal
  , value :: Internal
  }
  deriving (Show)

instance Default Attribute where
  def = Attribute none none

type MoeUnitT a = Writer (DList Element) a
type MoeUnit = MoeUnitT ()

type MoeCombinator = [Attribute] -> MoeUnit -> MoeUnit
type MoeCombinator' = MoeUnit -> MoeUnit

type LightCombinator = [Attribute] -> MoeUnit
type LightCombinator' = MoeUnit