module Text.HTML.Moe.Type where

import Data.Default
import Control.Monad.Writer
import Data.ByteString

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

instance Default Element where
  def = Element empty def def True

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

instance Default Attribute where
  def = Attribute empty empty

type MoeUnitT a = Writer [Element] a
type MoeUnit = MoeUnitT ()

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