prettychart-0.2.0.0: Pretty print charts from ghci.
Safe HaskellSafe-Inferred
LanguageGHC2021

Prettychart.Server

Description

Serve a chart web page with a web socket in it, that accepts ChartOptions.

Synopsis

Documentation

startChartServer :: Maybe String -> IO (ChartOptions -> IO Bool, IO ()) Source #

Start the chart server. Returns the chart consumer, and a server quit signal effect.

An iconic ghci session transcript:

> import Chart.Examples
> (sendChart, quitChartServer) <- startChartServer (Just "prettychart")
> sendChart unitExample

... point browser to localhost:9160 ...

> quitChartServer

startChartServerWith :: SocketConfig -> Page -> IO (ChartOptions -> IO Bool, IO ()) Source #

Start the chart server protocol with bespoke SocketConfig and Page configurations.

startChartServerWith (defaultSocketConfig & #port .~ 4567) (defaultSocketPage & #htmlBody %~ divClass_ "row" "bespoke footnote")

printChart :: Show a => Bool -> (ChartOptions -> IO Bool) -> a -> IO () Source #

Print a chart supplying a ChartOptions consumer, and a showable thing that may be chartable. The first argument flags whether to also print the item to stdout.

chartSocketPage :: Maybe ByteString -> Page Source #

Page containing a web socket and javascript needed to run it.