prettychart-0.3.0.1: 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.

startFileServerWith :: SocketConfig -> Page -> IO (FilePath -> IO Bool, IO ()) Source #

Start a file server protocol with bespoke SocketConfig and Page configurations.

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

watchE :: [Char] -> Codensity IO (Emitter IO Event) Source #

Emit from the fsnotify watch manager.

watchSvg :: FilePath -> CoEmitter IO FilePath Source #

Emit from the fsnotify watch manager. > glue' toStdout $| fmap (Text.pack . show) $ watchE "."

svgEvent :: Event -> Maybe FilePath Source #

Filter for svg file additions and modifications.

displayFile :: SocketConfig -> Page -> IO (Committer IO FilePath, IO ()) Source #

Create a file committer to serve an SVG file.