tutorial: add tutorial compiling script and conversion script
This commit is contained in:
parent
6afefdf611
commit
637de9d63f
4 changed files with 57 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -26,3 +26,4 @@ Setup
|
|||
shell.nix
|
||||
default.nix
|
||||
doc/_build
|
||||
doc/venv
|
||||
|
|
11
servant-examples/tutorial/check/check.sh
Executable file
11
servant-examples/tutorial/check/check.sh
Executable 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
|
15
servant-examples/tutorial/check/tinc.yaml
Normal file
15
servant-examples/tutorial/check/tinc.yaml
Normal 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
|
30
servant-examples/tutorial/convert.hs
Normal file
30
servant-examples/tutorial/convert.hs
Normal 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
|
Loading…
Reference in a new issue