ghci-websockets-0.0.2: A websocket server that survives GHCi reloads

Safe HaskellNone
LanguageHaskell2010

Ghci.Server

Contents

Synopsis

Documentation

This modules implements a websocket server whose state survives GHCi reloads. To use it, run start once per GHCi session, and then use sendText, sendHtml and sendPlot to show the values on all clients that are currently connected.

start :: IO () Source #

Start the server with default settings (HTTP on port 3000, websockets on port 9160)

startConfig :: Config -> IO () Source #

Start the websocket and HTTP servers using the config

Sending messages

sendText :: Text -> IO () Source #

Show a string.

>>> sendText "hello"

sendHtml :: Text -> IO () Source #

Insert some HTML into the DOM.

>>> sendHtml "<h1>Hello</h1>"

sendPlot :: [(Double, Double)] -> IO () Source #

Show a Plotly 2D line plot of the given points.

>>> sendPlot [(1, 2), (2, 5), (3, 4), (4, 3)]
>>> sendPlot $ fmap (\i -> let i' = (fromIntegral i / 10) in (i', sin i')) [1..100]

Configuration

data Config Source #

Server configuration

data Verbosity Source #

What to do with log messages

Constructors

Verbose

Write all log messages to stdout

Silent

Ignore all log messages

defaultConfig :: Config Source #

Default config, use ports 9160 (websockets) and 3000 (http) and ignore all log messages.

cfHTTPPort :: Config -> Int Source #

HTTP port

cfVerbosity :: Config -> Verbosity Source #

What to do with log messages

cfWSPort :: Config -> Int Source #

Websocket port