Popularity
8.5
Growing
Activity
0.0
Stable
47
8
5

Monthly Downloads: 8
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: Web     Network     N2O    

n2o-web alternatives and similar packages

Based on the "N2O" category.
Alternatively, view n2o-web alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of n2o-web or a related project?

Add another 'N2O' Package

README

N2O for Haskell

Build Status

Features

  • Endpoints: poor man's WebSocket and static HTTP server
  • Formatters: BERT
  • Protocols: NITRO
  • High Performance Protocol Relay
  • Smallest possible codebase — 500 LOC

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.

Setup

stack build
stack exec n2o-sample
open http://localhost:3000/samples/static/index.html

Nitro Protocol Demo

{-# LANGUAGE FlexibleContexts, OverloadedStrings, DeriveGeneric, DeriveAnyClass #-}
module Main (main) where

import Network.N2O
import Network.N2O.Web hiding (Event)
import GHC.Generics (Generic)
import Data.Serialize (Serialize)

data Example = Greet deriving (Show, Eq, Generic, Serialize)

main = runServer "localhost" 3000 cx

cx :: Cx Example
cx = mkCx{ cxMiddleware=[router]
         , cxProtos = [nitroProto]
         }

router [email protected]{cxReq=Req{reqPath=path}} =
  let handle = case path of
                  "/ws/samples/static/index.html" -> index
                  "/ws/samples/static/about.html" -> about
                  _ -> index
  in cx{cxHandler=mkHandler handle}

index Init = do
  updateText "system" "What is your name?"
  wire button{id_="send", postback=Just Greet, source=["name"]}
index (Message Greet) = do
  Just name <- get "name" -- wf:q/1
  updateText "system" ("Hello, " <> jsEscape name <> "!")
index ev = liftIO $ putStrLn ("Unknown event" <> show ev)
about Init = updateText "app" "This is the N2O Hello World App"
about ev = liftIO $ putStrLn ("Unknown event " <> show ev)

Credits

  • Andy Melnikov
  • Marat Khafizov
  • Maxim Sokhatsky