Hi all,
I'm trying to make a web server that manages its own state. The user can issue commands that modifies the state.
I did like below but unfortunatly the state is not keep after a command is issued...
What is the right way to do it? Is there any example sites with an internal state with happstack?

data Game = (the state of my game)
type NomicServer             = ServerPartT (StateT Game IO)

launchWebServer :: Game -> IO ()
launchWebServer initialState = do
   putStrLn "Starting web server...\nTo connect, drive your browser to \"http://localhost:8000/Login\""
   d <- getDataDir
   simpleHTTP' unpackStateT nullConf $ server d


server :: FilePath -> ServerPartT (StateT Game IO) Response
server d sh = mconcat [fileServe [] d, do
                                   decodeBody (defaultBodyPolicy "/tmp/" 4096 4096 4096)
                                   html <- implSite "http://localhost:8000/" "" nomicSite
                                   return $ toResponse html]

unpackStateT:: Game -> UnWebT (StateT Game IO) Response -> UnWebT IO Response
unpackStateT g w = evalStateT w g
 
--handler for web routes
nomicSite :: Site PlayerCommand (NomicServer Html)
nomicSite = setDefault (Noop 0) Site {
      handleSite         = \f url -> unRouteT (routedNomicCommands url) f
    , formatPathSegments = \u -> (toPathSegments u, [])
    , parsePathSegments  = parseSegments fromPathSegments
}


Thanks a lot,
Corentin