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

Safe HaskellNone
LanguageHaskell2010

Ghci.Websockets.Simple

Contents

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 broadcastText, broadcastHtml and broadcastPlot to show things in the browser window.

broadcastText :: Text -> IO () Source #

Show a string.

>>> broadcastText "hello"

broadcastHtml :: Text -> IO () Source #

Insert some HTML into the DOM.

>>> broadcastHtml "<h1>Hello</h1>"

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

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

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

Re-exports etc.

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)