module Text.HTML.Moe2.Type where

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

data Element = 
    Element
      {
        name :: Internal
      , elements :: [Element]
      , attributes :: [Attribute]
      , 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
  | Attributes [Attribute] Element
  deriving (Show)

instance Default Element where
  def = Element 
    {
      name = none
    , elements = def
    , attributes = 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 = MoeUnit -> MoeUnit

type LightCombinator = MoeCombinator
