N2O Haskell

The philosophy behind N2O is a simplicity, cleanness, and purity. The core of N2O should be no more than 500 LOC.

Listing 2. N2O Context Setup
data Example = Greet deriving (Show, Eq, Read) main = runServer "localhost" 3000 cx cx = createCx router router [email protected]{cxReq=Req{reqPath=path}} = let handler = case path of "/ws/samples/static/index.html" -> index "/ws/samples/static/about.html" -> about _ -> index in traceShow path cx{cxHandler=handler}

The idea to send prerendered JavaScript events over the wire belongs to Rusty Klophaus who made Nitrogen Erlang web framework. Later this was refined by N2O team and now is available in its purity of Haskell.

Listing 3. NITRO Web Protocol
index Init = do updateText "system" "What is your name?" wireEl button{id="send", postback=Just Greet, source=["name"]} index (Message Greet) = do Just name <- get "name" -- wf:q/1 updateText "system" ("Hello, " <> jsEscape name <> "!") about Init = updateText "app" "This is the N2O Hello World App"

The N2O does not limit in developing only web applications. N2O stack of protocols covers bus, storage, process interfaces. Subscribe to follow Haskell implementations.