Skip to content

Commit a4e75f8

Browse files
Release 0.1.0.0
2 parents 181c66a + 98e46dc commit a4e75f8

23 files changed

+1264
-0
lines changed

.github/workflows/ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- develop
8+
- main
9+
10+
jobs:
11+
cabal:
12+
name: "Cabal: GHC ${{ matrix.ghc }}"
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
ghc: ['8.2.2', '8.4.4', '8.6.5', '8.8.4', '8.10.2']
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
- name: Setup Haskell
21+
uses: actions/setup-haskell@v1.1.3
22+
with:
23+
ghc-version: ${{ matrix.ghc }}
24+
cabal-version: latest
25+
- name: Build
26+
run: cabal new-build --enable-tests --enable-benchmarks
27+
- name: Test
28+
run: cabal new-test --enable-tests
29+
30+
stack:
31+
name: "Stack: GHC ${{ matrix.ghc }}"
32+
runs-on: ubuntu-latest
33+
strategy:
34+
matrix:
35+
ghc: ['8.2.2', '8.4.4', '8.6.5', '8.8.4', '8.10.2']
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v2
39+
- name: Setup Haskell
40+
uses: actions/setup-haskell@v1.1.3
41+
with:
42+
ghc-version: ${{ matrix.ghc }}
43+
cabal-version: latest
44+
enable-stack: true
45+
stack-version: latest
46+
- name: Cache ~/.stack
47+
uses: actions/cache@v1
48+
with:
49+
path: ~/.stack
50+
key: ${{ runner.os }}-${{ matrix.ghc }}-stack
51+
- name: Build
52+
run: stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks
53+
env:
54+
STACK_YAML: stack-${{ matrix.ghc }}.yaml
55+
- name: Test
56+
run: stack test --system-ghc
57+
env:
58+
STACK_YAML: stack-${{ matrix.ghc }}.yaml

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# project
2+
/build/
3+
4+
# stack
5+
.stack-work
6+
*.yaml.lock
7+
stack-nix*
8+
9+
# cabal
10+
cabal.project.local
11+
cabal.project.local~
12+
/dist-newstyle/
13+
14+
# vi
15+
.*.swp

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# `redact-haskell` Changelog
2+
3+
This project follows the [Haskell package versioning policy][PVP], with
4+
versions in `A.B.C.D` format. `A` may be incremented arbitrarily for
5+
non-technical reasons, but [semantic versioning][SemVer] is otherwise
6+
followed, where `A.B` is the major version, `C` is the minor version, and `D`
7+
is the patch version. Initial development uses versions `0.0.0.D`, for which
8+
every version is considered breaking.
9+
10+
[PVP]: <https://pvp.haskell.org/>
11+
[SemVer]: <https://semver.org/>
12+
13+
The format of this changelog is based on [Keep a Changelog][KaC], with the
14+
following conventions:
15+
16+
* Level-two heading `Unreleased` is used to track changes that have not been
17+
released.
18+
* Other level-two headings specify the release in `A.B.C.D (YYYY-MM-DD)`
19+
format, with newer versions above older versions.
20+
* Level-three headings are used to categorize changes as follows:
21+
1. Breaking
22+
2. Non-Breaking
23+
* Changes are listed in arbitrary order and present tense.
24+
25+
[KaC]: <https://keepachangelog.com/en/1.0.0/>
26+
27+
## 0.1.0.0 (2020-11-28)
28+
29+
### Breaking
30+
31+
* Initial public release

LibOA.hs

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
------------------------------------------------------------------------------
2+
-- |
3+
-- Module : LibOA
4+
-- Description : supplementary functions for optparse-applicative
5+
-- Copyright : Copyright (c) 2019-2020 Travis Cardwell
6+
-- License : MIT
7+
--
8+
-- This is a collection of functions that I often use with
9+
-- @optparse-applicative@. I do not feel that it is worth maintaining yet
10+
-- another helper package on Hackage, so I just copy the code to different
11+
-- projects as required. If the library grows to a substantial size or others
12+
-- with to use it, I will reconsider.
13+
--
14+
-- Revision: 2020-01-02
15+
------------------------------------------------------------------------------
16+
17+
{-# LANGUAGE CPP #-}
18+
19+
module LibOA
20+
( -- * Options
21+
-- $Options
22+
helper
23+
, versioner
24+
-- * Utilities
25+
, commands
26+
-- * Help
27+
, (<||>)
28+
, section
29+
, table
30+
, vspace
31+
) where
32+
33+
-- https://hackage.haskell.org/package/ansi-wl-pprint
34+
import qualified Text.PrettyPrint.ANSI.Leijen as Doc
35+
import Text.PrettyPrint.ANSI.Leijen (Doc)
36+
37+
-- https://hackage.haskell.org/package/base
38+
import qualified Data.List as List
39+
#if !MIN_VERSION_base (4,11,0)
40+
import Data.Monoid ((<>))
41+
#endif
42+
43+
-- https://hackage.haskell.org/package/optparse-applicative
44+
import qualified Options.Applicative as OA
45+
import qualified Options.Applicative.Common as OAC
46+
import qualified Options.Applicative.Types as OAT
47+
48+
------------------------------------------------------------------------------
49+
-- $Options
50+
--
51+
-- Option descriptions are not capitalized.
52+
53+
-- | A hidden @-h@ / @--help@ option that always fails, showing the help
54+
--
55+
-- This is the same as 'OA.helper' except that it has a different help
56+
-- message.
57+
helper :: OA.Parser (a -> a)
58+
helper = OA.abortOption OA.ShowHelpText $ mconcat
59+
[ OA.short 'h'
60+
, OA.long "help"
61+
, OA.help "show help and exit"
62+
, OA.hidden
63+
]
64+
65+
-- | A hidden @--version@ option that always fails, showing the version
66+
versioner
67+
:: String -- ^ version string
68+
-> OA.Parser (a -> a)
69+
versioner verStr = OA.infoOption verStr $ mconcat
70+
[ OA.long "version"
71+
, OA.help "show version and exit"
72+
, OA.hidden
73+
]
74+
75+
------------------------------------------------------------------------------
76+
-- $Utilities
77+
78+
-- | Get a list of commands for a parser
79+
commands :: OA.Parser a -> [String]
80+
commands =
81+
let go _ opt = case OAT.optMain opt of
82+
OAT.CmdReader _ cmds _ -> reverse cmds
83+
_ -> []
84+
in concat . OAC.mapParser go
85+
86+
------------------------------------------------------------------------------
87+
-- $Help
88+
89+
-- | Insert a blank line between two documents
90+
(<||>) :: Doc -> Doc -> Doc
91+
d1 <||> d2 = d1 <> Doc.line <> Doc.line <> d2
92+
93+
-- | Create a section with a title and indented body
94+
section :: String -> Doc -> Doc
95+
section title = (Doc.text title Doc.<$$>) . Doc.indent 2
96+
97+
-- | Create a two-column table
98+
table :: [(String, String)] -> Doc
99+
table rows =
100+
let width = 1 + maximum (map (length . fst) rows)
101+
in Doc.vcat
102+
[ Doc.fillBreak width (Doc.text l) Doc.<+> Doc.text r
103+
| (l, r) <- rows
104+
]
105+
106+
-- | Vertically space documents with blank lines between them
107+
vspace :: [Doc] -> Doc
108+
vspace = mconcat . List.intersperse (Doc.line <> Doc.line)

0 commit comments

Comments
 (0)