packages feed

simple-0.6.0: template/Common_hs.tmpl

module {{module}}.Common where

import Control.Applicative
import Web.Simple

-- Uncomment the following lines for database, templates, and session support
--import Web.Simple.PostgreSQL
--import Web.Simple.Templates
--import Web.Simple.Session

type AppSettings = ()

newAppSettings :: IO AppSettings
newAppSettings = return ()

{- Replace the above code with this comment block for database, templates and
 - session support. Don't forget to uncomment the relevant packages in the
 - cabal file and the import statements at the top of this file.

data AppSettings = AppSettings { appDB :: PostgreSQLConn
                               , appSession :: Maybe Session }

newAppSettings :: IO AppSettings
newAppSettings = do
  db <- createPostgreSQLConn
  return $ AppSettings { appDB = db , appSession = Nothing }

instance HasPostgreSQL AppSettings where
  postgreSQLConn = appDB

instance HasSession AppSettings where
  getSession = appSession
  setSession sess = do
    cs <- controllerState
    putState $ cs { appSession = Just sess }

instance HasTemplates AppSettings where
  defaultLayout = Just <$> getTemplate "templates/main.html"

-}