{-# 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 $ Simple HSP w/ Happstack Example

HSP can be convenient

  1. You can include your html in your Haskell file exactly as you'd expect.
  2. You can include <%"haskell values"%> very easily in your code.
  3. Or even IO actions: <%aux%>.
  4. Your HTML is parsed and built at compile time, so that is where mistakes are caught
where aux = doIO $ show `fmap` randomRIO (0,100 :: Int)