readme-lhs: See

[ bsd3, development, library, program ] [ Propose Tags ]

See for description.

[Skip to Readme]
Versions [faq], 0.2.0
Dependencies base (>=4.7 && <5), containers, optparse-generic, pandoc, pandoc-types, protolude, readme-lhs, text [details]
License BSD-3-Clause
Copyright 2016 Tony Day
Author Tony Day
Category Development
Home page
Bug tracker
Source repo head: git clone
Uploaded by tonyday567 at Tue Jul 23 05:21:10 UTC 2019
Distributions NixOS:0.2.0
Executables readme-lhs-example
Downloads 468 total (21 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2019-07-23 [all 1 reports]


[Index] [Quick Jump]


Maintainer's Corner

For package maintainers and hackage trustees

Readme for readme-lhs-0.2.0

[back to package description]

readme-lhs Build Status

<blockquote cite> The language in which we express our ideas has a strong influence on our thought processes. ~ Knuth </blockquote>

This is an example of mixing literate haskell with markdown, and in using Readme.Lhs. The file is composed of several elements:

  • literate haskell. Bird-tracks are used, as the alternative method is latex rather than markdown, which doesn’t survive a pandoc round trip.

  • markdown. All non bird-tracked lines are considered to be markdown. It’s probably incompatible with haddock, but this may well resolve with adoption of the literate markdown ghc proposal.

  • fenced code blocks with an output class, which are used to insert computation results. The fenced code blocks look like:

    ```{.output .example} ```

ghc options

{-# OPTIONS_GHC -Wall #-}


-- doctest doesn't look at the cabal file, so you need pragmas here
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}


import Protolude
import Readme.Lhs


main :: IO ()
main = do
  let n = 10
  let answer = product [1..n::Integer]
  _ <- runOutput ("example.lhs", LHS) ("", GitHubMarkdown) $ do
    output "example1" "Simple example of an output"
Simple example of an output
    output "example2" (show answer)

10! is equal to:

  pure ()

Output that doesn’t exist is simply cleared.

hsfiles writeup

A literate-programming friendly; tight work-flow stack template.



This is my latest working template, overly influenced by lexi-lambda’s opinionated guide. The template includes:

  • some minor tweaks to protolude
  • lens, foldl, formatting & text as must have libraries
  • generic-lens-labels


stack build --exec "$(stack path --local-install-root)/bin/readme-lhs-example" --file-watch