Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
A haskell library to serve charts via ghci.
Synopsis
- module Prettychart.Server
- module Prettychart.Any
- module Prettychart.Charts
Usage
> -- :set -package prettychart > import Prettychart > (sendChart, quitChartServer) <- startChartServer (Just "prettychart")
An example from chart-svg ...
> import Chart.Examples > sendChart lineExample
... point your browser at localhost:9160 and you should see this:
Utilising -interactive-print, we can turn these protocols into a pretty printer for collections of numbers:
> printc = printChart False sendChart > :t printc > (Show a) => a -> IO () > :set -interactive-print printc > [0..9]
A bar chart representing this list will be rendered in the browser, and should look like this:
... stop the server, and go back to normal.
> quitChartServer > :set -interactive-print print
All of this can be automated by dropping the code below into a ghci.conf
-- :set -package prettychart :{ :def! prettychart \_ -> pure $ unlines [ "import Prettychart", "(sendChart, quitChartServer) <- startChartServer Nothing", "printc=printChart False sendChart", ":set -interactive-print printc" ] :} :{ :def! noprettychart \_ -> pure $ unlines [ "quitChartServer", ":set -interactive-print print" ] :} :prettychart
Re-exports
module Prettychart.Server
module Prettychart.Any
module Prettychart.Charts