knit-haskell: a minimal Rmarkdown sort-of-thing for haskell, by way of Pandoc

[ bsd3, library, text ] [ Propose Tags ]

knit-haskell is a beginning attempt at bringing some of the benefits of Rmarkdown to Haskell. It includes an effects stack (using polysemy rather than mtl) which includes logging, a simplified interface to Pandoc and various writer-like effects to intersperse document building with regular code. Various helper functions are provided to simplify common operations, making it especially straightforward to build an HTML document from bits of markdown, latex and Lucid or Blaze html. Support is also included for including hvega visualizations and diagrams from the diagrams package. More information is available in the readme.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.2.0.0, 0.3.0.0, 0.4.0.0, 0.5.0.0, 0.6.0.0, 0.6.0.1, 0.7.0.0, 0.8.0.0 (info)
Change log ChangeLog.md
Dependencies aeson-pretty (>=0.8.7 && <0.9), base (>=4.12.0 && <4.13), base64-bytestring (>=1.0.0.2 && <1.1.0.0), blaze-colonnade (>=1.2.2 && <1.3.0.0), blaze-html (>=0.9.1 && <0.10), bytestring (>=0.10.8 && <0.11), case-insensitive (>=1.2.0.11 && <1.3.0.0), colonnade (>=1.1 && <1.3), constraints (>=0.10 && <0.12), containers (>=0.5.0 && <0.7), diagrams-lib (>=1.4 && <1.5.0.0), diagrams-svg (>=1.4.1 && <1.5.0.0), directory (>=1.3.3.0 && <1.4.0.0), Glob (>=0.10.0 && <0.11.0), http-client (>=0.6.4 && <0.7.0), http-client-tls (>=0.3.5.3 && <0.4.0.0), http-types (>=0.12.3 && <0.13.0), hvega (>=0.1.0 && <=0.2.0.0), logging-effect (>=1.3.3 && <1.4), lucid (>=2.9.11 && <2.10), mtl (>=2.2.2 && <2.3), network (>=2.8.0.0 && <3.2.0.0), network-uri (>=2.6.1.0 && <2.7.0.0), pandoc (>=2.7.2 && <2.8), polysemy (>=0.3.0.0 && <0.5.0.0), polysemy-plugin (>=0.2.0.0 && <0.3.0.0), polysemy-zoo (>=0.3.0.0 && <0.4.0), prettyprinter (>=1.2.1 && <1.4), random (>=1.1 && <1.2), random-fu (>=0.2.7 && <0.3), random-source (>=0.3.0 && <0.4), svg-builder (>=0.1.1 && <0.2), text (>=1.2.3 && <1.3), time (>=1.8.0 && <2.0.0) [details]
License BSD-3-Clause
Copyright 2019 Adam Conner-Sax
Author Adam Conner-Sax
Maintainer adam_conner_sax@yahoo.com
Category Text
Bug tracker https://github.com/adamConnerSax/knit-haskell/issues
Source repo head: git clone https://github.com/adamConnerSax/knit-haskell
Uploaded by adamCS at 2019-06-21T14:38:16Z
Distributions
Downloads 3076 total (21 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for knit-haskell-0.6.0.1

[back to package description]

knit-haskell v0.6.0.0

Build Status Hackage Hackage Dependencies

Introduction

knit-haskell is an attempt to emulate parts of the RMarkdown/knitR experience in haskell. The idea is to be able to build HTML (or, perhaps, some other things Pandoc can write) inside a haskell executable.
This package has some wrapping around Pandoc and the PandocMonad as well as logging facilities and some support for inserting hvega visualizations.
All of that is handled via writer-like effects, so additions to the documents can be interspersed with regular haskell code.

Supported Inputs

Examples

There are a few examples in the "examples" directory.

  • SimpleExample demonstrates the bare bones features of the library. Creating a document from a few fragments and then "knitting" it into HTML text and writing that to a file. This includes hvega, diagrams and plots examples.
  • MultiDocExample demonstrates how to build multiple documents.
  • MtlExample demonstrates the same simple features as above, but runs them atop an example mtl stack, allowing access to the mtl stack's functionality during document assembly.
  • RandomExample builds on the mtl example to show how you can also add an additional polysemy effect (in this case, Polysemy.RandomFu from polysemy-RandomFu) to your document-building. This one also demonstrates a use of colonnade for adding a formatted table to the document.
  • ErrorExample.
    Similar to "SimpleExample" but throws a user error during document assembly.

Notes

  • You should be able to get everything you need by just importing the Knit.Report module. That has the main functions for "knitting" documents from fragments and re-exports all the required functions to input the supported fragment types and create/write Html.
  • This uses polysemy for its effect management rather than mtl.
    Polysemy's inference and performance are greatly improved if you enable the polysemy-plugin, which involves:
  1. adding "polysemy-plugin" in build-depends and
  2. Add "ghc-options: -fplugin=Polysemy.Plugin" to your package configuration. Pandoc effects and writer effects for document building are also provided.
  • Polysemy is capable of "absorbing" some mtl-style monad constraints. This is demonstrated in RandomExample and composable absorbers for MonadReader, MonadWriter, MonadState and MonadError can be found in the polysemy-zoo.

  • Pandoc templates are included for HTML output. See the examples for how to access them or specify others.

  • Though you can theoretically output to any format Pandoc can write--and it would be great to add some output formats!--some features only work with some output formats. My goal was the production of Html and that is the only output format that supports the hvega charting since hvega itself is just a wrapper that builds javascript to render in a browser.
    And so far that is the only supported output format.

  • This is very much a WIP. So it's rough around the edges and in the middle. If you find it useful but have suggestions, please submit issues on github.

  • I'm very interested in adding to the "zoo" of input fragments. Any PRs of that sort would be most welcome!

  • I'm also interested in widening the possible output types--currently only HTML is supported--but that is quite limited now by hvega which only works in html output.
    But support could be added for other output types if hvega input is not required.