N2O

INTRO

The n2o module contains request and context definition, state and N2O functors.

REQUEST

Listing 1. HTTP Request
type Req = { path : string , method : string , version : string , headers : (string * string) list }
Listing 2. HTTP Request Constructor
fun mkReq () = { path = "" , method = "" , version = "HTTP/1.1" , headers = [] }

CONTEXT

Listing 3. N2O Protocol Closure
datatype 'a Ev = Init | Message of 'a | Terminate
Listing 4. N2O Protocol Result
datatype 'a Res = Reply of 'a | Ok | Unknown | Empty
Listing 5. N2O Context Record
type 'a Cx = { req : Req , module : 'a Ev -> 'a Res } val 'a mod_ : 'a Ev -> 'a Res = fn _ => Empty signature BASE = sig type t type 'a prot end signature BASE_EXT = sig include BASE val handlers : (t Hnd) list val protos : ((t prot) Proto) list end signature CX = sig include BASE_EXT val cx : t Cx end
Listing 6. N2O Context Constructor
functor MkCx (M: BASE_EXT) :> CX = struct type t = M.t type 'a prot = 'a M.prot val cx = { req = mkReq (), module = mod_ } val handlers = M.handlers val protos = M.protos end

IO

Listing 7. N2O PROTO
type 'a Proto = 'a -> 'a Res type 'a Hnd = 'a Cx -> 'a Cx

This module may refer to: SERVER