{-# LANGUAGE QuasiQuotes #-}

module Main where

import Lighttpd.Conf
import Lighttpd.Conf.QQ
import Language.Haskell.Meta

main :: IO ()
main = do
  (putStrLn . render . pprWithMode Spaced) config
  putStrLn (replicate 78 '-')
  (putStrLn . prettyPrint . fromRight . parseHsExp . show) config

config :: Config
config = [$lighttpd|
  # default document-root
  server.document-root = "/var/www/example.org/pages/"

  # TCP port
  server.port = 80
  # selecting modules
  server.modules = ( "mod_access", "mod_rewrite" )

  # variables, computed when config is read.
  var.mymodule = "foo"
  server.modules += ( "mod_" + var.mymodule )
  # var.PID is initialised to the pid of lighttpd before config is parsed

  # include, relative to dirname of main config file
  includeOHNOESANERRSOIUSOUROUBBDF "mime.types.conf"

  # read configuration from output of a command
  include_shell "/usr/local/bin/confmimetype /etc/mime.types"
|]