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]
Versions [faq] 0.1.0
Change log
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
Category Statistics
Home page
Bug tracker
Uploaded by glutamate at 2017-06-06T13:32:08Z
Distributions LTSHaskell:0.1.0, NixOS:0.1.0, Stackage:0.1.0
Executables inlitpp
Downloads 1009 total (3 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs not available [build log]
All reported builds failed as of 2017-06-06 [all 3 reports]


  • Inliterate
    • Inliterate.Import
    • Inliterate.Inspect


Maintainer's Corner

For package maintainers and hackage trustees

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 which ccompiles into

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)


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.


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