{-# OPTIONS_GHC -F -pgmFtrhsx #-}
-- You might be wondering what's the point of this options declaration.
-- It enables a particular preprocessor that allows the literal HTML syntax
-- for HSP. Without it this example cannot compile.
import Happstack.Server
import Happstack.Server.HSP.HTML
import HSP
import System.Random
main :: IO ()
main = simpleHTTP nullConf{port=8080} home
{- Integrating HSP into Happstack is very simple. One just lifts the HSP value into a ServerPartT with webHSP from
Happstack.Server.HSP.HTML -}
home :: ServerPartT IO Response
home = webHSP $ <html>
<head>
<title>Simple HSP w/ Happstack Example</title>
</head>
<body>
<h1>HSP can be convenient</h1>
<ol>
<li>You can include your html in your Haskell file exactly as you'd expect.</li>
<li>You can include <%"haskell values"%> very easily in your code.</li>
<li>Or even IO actions: <%aux%>.</li>
<li>Your HTML is parsed and built at compile time, so that is where mistakes are caught</li>
</ol>
</body>
</html>
where aux = doIO $ show `fmap` randomRIO (0,100 :: Int)