tutorial: add tutorial compiling script and conversion script
commitdb602e8a79ad8eee652bd3d7e2be74787d11a34a
authorSönke Hahn <soenkehahn@gmail.com>
dateTue 26 Jan 2016, 00:27 (11 years ago)
parent1d4e3a1
.gitignore+1
@@ -26,3 +26,4 @@ Setup
2626shell.nix
2727default.nix
2828doc/_build
29+doc/venv
servant-examples/tutorial/check/check.shnew file+11
@@ -0,0 +1,11 @@
1+#!/usr/bin/env bash
2+
3+set -o errexit
4+
5+# tinc
6+
7+cabal exec -- ghc -Wall -Werror -outputdir build-output ../api-type.lhs -O0 -c -pgmL markdown-unlit
8+#cabal exec -- ghc -Wall -Werror -outputdir build-output ../server.lhs -O0 -c -fno-warn-missing-methods -fno-warn-name-shadowing
9+#cabal exec -- ghc -Wall -Werror -outputdir build-output ../client.lhs -O0 -c -fno-warn-missing-methods -fno-warn-name-shadowing
10+#cabal exec -- ghc -Wall -Werror -outputdir build-output ../javascript.lhs -O0 -c -fno-warn-missing-methods
11+#cabal exec -- ghc -Wall -Werror -ibuild-output -outputdir build-output ../docs.lhs -O0 -c -fno-warn-missing-methods
servant-examples/tutorial/check/tinc.yamlnew file+15
@@ -0,0 +1,15 @@
1+dependencies:
2+ - name: servant
3+ path: ../../../servant
4+ - name: servant-server
5+ path: ../../../servant-server
6+ - name: servant-client
7+ path: ../../../servant-client
8+ - name: servant-js
9+ path: ../../../servant-js
10+ - name: servant-lucid
11+ path: ../../../servant-lucid
12+ - name: servant-docs
13+ path: ../../../servant-docs
14+ - name: servant-foreign
15+ path: ../../../servant-foreign
servant-examples/tutorial/convert.hsnew file+30
@@ -0,0 +1,30 @@
1+
2+import Control.Arrow
3+import Data.Foldable
4+import Data.List
5+import System.Environment
6+
7+main = do
8+ files <- getArgs
9+ forM_ files $ \ file -> do
10+ convertM file
11+
12+convertM :: FilePath -> IO ()
13+convertM file = do
14+ contents <- readFile file
15+ seq (length contents) (return ())
16+ writeFile file (convert contents)
17+
18+convert :: String -> String
19+convert =
20+ lines >>>
21+ groupBy (\ a b -> take 1 a == take 1 b) >>>
22+ map go >>>
23+ concat >>>
24+ unlines
25+ where
26+ go :: [String] -> [String]
27+ go (a : r)
28+ | ">" `isPrefixOf` a
29+ = "``` haskell" : map (drop 2) (a : r) ++ "```" : []
30+ go x = x