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

Safe HaskellNone
LanguageHaskell2010

Ghci.Server.Websockets.Message

Synopsis

Documentation

This module provides the Message data type, and various constructors for it. It is intended to be used together with the 'html/index.html' file.

Usage

  1. Start a GHCi session and run initialiseDef
  2. Open html/index.html in a browser (it's self-contained, no http server required)
  3. Use sendText, sendHtml and sendPlot to show things in the browser window.

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]

data Message Source #

Constructors

MsgText Text

A string

MsgHtml Text

An HTML fragment

MsgPlotly [Value] Value

The 'data' and layout parameters used for newPlot (see https://plot.ly/javascript/plotlyjs-function-reference/#plotlynewplot). The first parameter is a list of Plotly traces (See https://plot.ly/javascript/reference/, "Trace types"), the second parameter is a Plotly layout value (see https://plot.ly/javascript/reference/, Layout)