Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Prettychart.Server
Description
Serve a chart web page with a web socket in it, that accepts ChartOptions
.
Synopsis
- startChartServer :: Maybe String -> IO (ChartOptions -> IO Bool, IO ())
- startChartServerWith :: SocketConfig -> Page -> IO (ChartOptions -> IO Bool, IO ())
- printChart :: Show a => Bool -> (ChartOptions -> IO Bool) -> a -> IO ()
- chartSocketPage :: Maybe ByteString -> Page
- startFileServerWith :: SocketConfig -> Page -> IO (FilePath -> IO Bool, IO ())
- watchE :: [Char] -> Codensity IO (Emitter IO Event)
- watchSvg :: FilePath -> CoEmitter IO FilePath
- svgEvent :: Event -> Maybe FilePath
- displayFile :: SocketConfig -> Page -> IO (Committer IO FilePath, IO ())
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")
displayFile :: SocketConfig -> Page -> IO (Committer IO FilePath, IO ()) Source #
Create a file committer to serve an SVG file.