inliterate: Interactive literate programming

[ library, mit, program, statistics ] [ Propose Tags ]

Evaluate markdown code blocks to show the results of running the code.


[Skip to Readme]

Modules

  • Inliterate
    • Inliterate.Import
    • Inliterate.Inspect

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0
Change log changelog.md
Dependencies base (>=4.6 && <5), blaze-html, cheapskate, containers, haskell-src-exts, inliterate, lucid, lucid-extras, plotlyhs, text, time [details]
License MIT
Author Tom Nielsen
Maintainer tomn@diffusionkinetics.com
Category Statistics
Home page https://github.com/diffusionkinetics/open/inliterate
Bug tracker https://github.com/diffusionkinetics/open/issues
Uploaded by glutamate at 2017-06-06T13:32:08Z
Distributions NixOS:0.1.0
Reverse Dependencies 2 direct, 0 indirect [details]
Executables inlitpp
Downloads 1339 total (7 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2017-06-06 [all 3 reports]

Readme for inliterate-0.1.0

[back to package description]

inliterate: Dynamic reporting for Haskell

The aim of inliterate is generate dynamic markdown reports from literate Haskell code in which code blocks can be evaluated to present the results of analyses in textual or graphical form.

inliterate is a GHC preprocessor which transforms a markdown document into a Haskell program, which, when run, prints to stdout the input document in HTML format. Certain code blocks with special annotations can be treated in particular ways: as Haskell code that must be included in the generating program (at the top level or in a do block) and as code that must be evaluated with the results inserted into the HTML document.

For an example document, see https://github.com/diffusionkinetics/open/blob/master/plotlyhs/gendoc/GenDocInlit.hs which ccompiles into https://glutamate.github.io/plotlyhs/.

The inliterate document

The inliterate ddocument should contain the following pragma on the first line or after the LANGUAGE pragmas:

{-# OPTIONS_GHC -F -pgmF inlitpp #-}

this tells GHC to invoke the preprocessor.

Code blocks

inliterate gives special meaning to the following code block language annotations (see the plotlyhs documentation generator to see how these are invoked)

html_header

this HTML should go in the header. Use this to load JavaScript or CSS, for instance for graphing libraries.

haskell top

Haskell code that is added to the top level

haskell do

Haskell code that is added to the main do block. use this for loading data or otherwise performing input and output.

haskell eval

Haskell code that is evaluated. The resultant type must be an instance of the AskInliterate class ddefined in Inliterate.Import.

hide

add this to top or do code to prevent it from being printed in the output document (but it is still run)

How to run

As an excutable

if you only have a few documents, you can put them in your cabal file as an executable, with inliterate as a build dependency.

here's the example from the plotlyhs documentation generator:

executable plotly-gendoc
  main-is: GenDocInlit.hs
  build-depends:       base >=4.6 && <5
                     , plotlyhs
                     , lucid
                     , aeson
                     , text
                     , microlens
                     , plotlyhs
                     , inliterate
                     , datasets
                     , neat-interpolation

Using stack runghc

if you have a larger number, or dynamically changing, set of documents, you can run them individually using stack runghc. inliterate should be listed in your cabal file as a build dependency to make sure the package is visible.

stack runghc InliterateFile.hs

if you want only the body HTML and not the headers, you can pass the argument --no-inlit-wrap to the executable

stack runghc InliterateFile.hs -- --no-inlit-wrap