packages feed

chu2-2012.11.20: readme.md

Chu2 Agda Web Server Interface
===============================

## hello world example

```agda
module Hello where

open import IO              using (return) renaming (run to io)
open import Data.List       using ([])
open import Function        using (const)
open import Chu2            using (response; OK; Application) 

hello-world-response = response OK [] ("Hello Agda!")

hello-world-app : Application
hello-world-app = const (return hello-world-response)

open import Chu2.Handler.SnapServer using (on-port_run)
main = io (on-port 3000 run hello-world-app)
```

## Using Middleware

```agda
module Hello2 where

-- simple-logger middleware
open import Chu2.Middleware.SimpleLogger using (simple-logger)

open import IO              using (return) renaming (run to io)
open import Function        using (const)
open import Chu2            using (Application; default-response)

default-app : Application
default-app = const (return default-response)

app : Application
app = simple-logger default-app

open import Chu2.Handler.SnapServer using (on-port_run)
main = io (on-port 3001 run app)
```

## Full spec

[`Chu2.agda`](https://github.com/nfjinjing/chu2/blob/master/src/Chu2.agda)

## Note

* need the Agda standard library: <http://wiki.portal.chalmers.se/agda/pmwiki.php?n=Libraries.StandardLibrary>
* need to read the Agda tutorial and be able to run Agda script from emacs: <http://www.cse.chalmers.se/~ulfn/papers/afp08/tutorial.pdf>