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
      }
  | 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 none def def True

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