packages feed

happs-tutorial-0.2: templates/main-function.st

<h3>Where it all begins: the function main</h3>

<p>Have a look at <a href="/src/Main.hs">main</a> function at the core of this web application.</p>

<p>Two bits of code that should jump out at you as being important are "entrypoint" and "controller".</p>

<p>So, open this file in ghci: cd src; ghci Main.hs and have a look at these functions using ghci :i .</p>

<p>*Main> :info entryPoint
<br>entryPoint :: HAppS.Data.Proxy.Proxy Session.State
<br>  	-- Defined at <a href="/src/Model.hs">Model.hs</a>...
<br>*Main> :i controller
<br>controller :: [ServerPartT IO Response]
<br>  	-- Defined at <a href="/src/Controller.hs">Controller.hs</a>...
</p>

<p>The entrypoint function has to do with the HAppS state system, and we'll pospone learning about it for later.</p>

<p>The controller function is a list of ServerPartTs, which are basically handlers that
accept an HTTP request and return a response. We look at what is going on in the controller code in
<a href="/tutorial/basic-url-handling">basic url handling</a>, next.
</p>

$! 
<p>Now you have a choice about what to read next.</p>

<p>If you are in a hurry to write a HAppS application without delving too much into what's going on behind the scenes,
read , which looks at what's happening in the controller code.</p>

<p>If you want to understand the HAppS type system in more detail, read <a href="understanding-happs-types">understanding HAppS types</a>.
</p>
!$