web-rep-0.1.2: representations of a web pag

Safe HaskellNone
LanguageHaskell2010

Web.Page.Bridge

Synopsis

Documentation

sendc :: Engine -> Text -> IO () Source #

append :: Engine -> Text -> Text -> IO () Source #

replace :: Engine -> Text -> Text -> IO () Source #

data Engine #

An Engine is a handle to a specific JavaScript engine

start :: (Engine -> IO ()) -> Application -> Application #

This accepts WebSocket requests, calls the callback with an Engine that can be used to access JavaScript.

type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived #

The WAI application.

Note that, since WAI 3.0, this type is structured in continuation passing style to allow for proper safe resource handling. This was handled in the past via other means (e.g., ResourceT). As a demonstration:

app :: Application
app req respond = bracket_
    (putStrLn "Allocating scarce resource")
    (putStrLn "Cleaning up")
    (respond $ responseLBS status200 [] "Hello World")

midShared :: Show a => SharedRep IO a -> (Engine -> Rep a -> StateT (HashMap Text Text) IO ()) -> (Engine -> Either Text (HashMap Text Text, Either Text a) -> IO ()) -> Application -> Application Source #

create Wai Middleware for a SharedRep providing an initialiser and action on events