N2O Haskell

N2O defines a way we scale protocols, database schema, applications and services across companies, formatters, views and presentation layers. At the core N2O folds a list of protocols and their handlers providing a minimal type-level specification for general purpose application protocol tract.

As example this Haskell version of N2O is shipped with Nitro protocol implementation, that listens the tract and push prerendered JavaScript events back to the channel. This smart and simple reactive way of client-server interaction first was used by Rusty Klophaus in his Nitrogen web framework, that was pushed forward since then in N2O by Andy Melnikov and Marat Khafizov.

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.

You may want to read: WEB, INT.