tutorial: add tutorial compiling script and conversion script

This commit is contained in:
Sönke Hahn 2016-01-26 00:27:07 +01:00
parent 1d4e3a1e5b
commit db602e8a79
4 changed files with 57 additions and 0 deletions

1
.gitignore vendored
View file

@ -26,3 +26,4 @@ Setup
shell.nix shell.nix
default.nix default.nix
doc/_build doc/_build
doc/venv

View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -o errexit
# tinc
cabal exec -- ghc -Wall -Werror -outputdir build-output ../api-type.lhs -O0 -c -pgmL markdown-unlit
#cabal exec -- ghc -Wall -Werror -outputdir build-output ../server.lhs -O0 -c -fno-warn-missing-methods -fno-warn-name-shadowing
#cabal exec -- ghc -Wall -Werror -outputdir build-output ../client.lhs -O0 -c -fno-warn-missing-methods -fno-warn-name-shadowing
#cabal exec -- ghc -Wall -Werror -outputdir build-output ../javascript.lhs -O0 -c -fno-warn-missing-methods
#cabal exec -- ghc -Wall -Werror -ibuild-output -outputdir build-output ../docs.lhs -O0 -c -fno-warn-missing-methods

View file

@ -0,0 +1,15 @@
dependencies:
- name: servant
path: ../../../servant
- name: servant-server
path: ../../../servant-server
- name: servant-client
path: ../../../servant-client
- name: servant-js
path: ../../../servant-js
- name: servant-lucid
path: ../../../servant-lucid
- name: servant-docs
path: ../../../servant-docs
- name: servant-foreign
path: ../../../servant-foreign

View file

@ -0,0 +1,30 @@
import Control.Arrow
import Data.Foldable
import Data.List
import System.Environment
main = do
files <- getArgs
forM_ files $ \ file -> do
convertM file
convertM :: FilePath -> IO ()
convertM file = do
contents <- readFile file
seq (length contents) (return ())
writeFile file (convert contents)
convert :: String -> String
convert =
lines >>>
groupBy (\ a b -> take 1 a == take 1 b) >>>
map go >>>
concat >>>
unlines
where
go :: [String] -> [String]
go (a : r)
| ">" `isPrefixOf` a
= "``` haskell" : map (drop 2) (a : r) ++ "```" : []
go x = x