module Text.HPaco.Writer 
    ( Writer
    , WriterOptions (..)
    , defaultWriterOptions
    ) where

import Text.HPaco.AST (AST)
import Text.HPaco.Writers.Internal.WrapMode
import Text.HPaco.Writers.Internal.CodeWriter

data WriterError =
    WriterError { writerErrorMessage :: String }
    deriving (Show)
type Writer = AST -> String

data WriterOptions =
    WriterOptions { woPrettyPrint :: Bool
                  , woIndentStr :: String
                  , woTemplateName :: String
                  , woIncludePreamble :: Bool
                  , woWrapMode :: WrapMode
                  , woExposeAllFunctions :: Bool
                  , woWriteFunc :: String
                  }

defaultWriterOptions =
    WriterOptions { woPrettyPrint = False
                  , woIndentStr = "\t"
                  , woTemplateName = ""
                  , woIncludePreamble = True
                  , woWrapMode = WrapNone
                  , woExposeAllFunctions = False
                  , woWriteFunc = ""
                  }

instance CodeWriterOptions WriterOptions where
    cwoIndent = woIndentStr
    cwoNewline = \_ -> "\n"