readme-lhs: See readme.md

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

See readme.md for description.


[Skip to Readme]
Versions [faq] 0.1.0.0, 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
Maintainer tonyday567@gmail.com
Category Development
Home page https://github.com/tonyday567/readme-lhs#readme
Bug tracker https://github.com/tonyday567/readme-lhs/issues
Source repo head: git clone https://github.com/tonyday567/readme-lhs
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]

Modules

[Index] [Quick Jump]

Downloads

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 #-}

pragmas

-- 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 #-}

libraries

import Protolude
import Readme.Lhs

code

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

10! is equal to:

3628800
  pure ()

Output that doesn’t exist is simply cleared.


hsfiles writeup

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

other/readme-lhs.hsfiles

other/batteries.hsfiles

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

workflow

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