Skip to content

Commit 4179c1d

Browse files
committed
Initial commit
0 parents  commit 4179c1d

File tree

12 files changed

+645
-0
lines changed

12 files changed

+645
-0
lines changed

.github/workflows/fourmolu.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Fourmolu
2+
on: push
3+
jobs:
4+
format:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v3
8+
- uses: haskell-actions/run-fourmolu@v10
9+
with:
10+
version: "0.15.0.0"

.github/workflows/haskell-ci.yml

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
# This GitHub workflow config has been generated by a script via
2+
#
3+
# haskell-ci 'github' '--config=cabal.haskell-ci' 'cabal.project'
4+
#
5+
# To regenerate the script (for example after adjusting tested-with) run
6+
#
7+
# haskell-ci regenerate
8+
#
9+
# For more information, see https://github.com/haskell-CI/haskell-ci
10+
#
11+
# version: 0.19.20240708
12+
#
13+
# REGENDATA ("0.19.20240708",["github","--config=cabal.haskell-ci","cabal.project"])
14+
#
15+
name: Haskell-CI
16+
on:
17+
push:
18+
branches:
19+
- master
20+
pull_request:
21+
branches:
22+
- master
23+
jobs:
24+
linux:
25+
name: Haskell-CI - Linux - ${{ matrix.compiler }}
26+
runs-on: ubuntu-20.04
27+
timeout-minutes:
28+
60
29+
container:
30+
image: buildpack-deps:jammy
31+
continue-on-error: ${{ matrix.allow-failure }}
32+
strategy:
33+
matrix:
34+
include:
35+
- compiler: ghc-9.10.1
36+
compilerKind: ghc
37+
compilerVersion: 9.10.1
38+
setup-method: ghcup
39+
allow-failure: false
40+
- compiler: ghc-9.8.2
41+
compilerKind: ghc
42+
compilerVersion: 9.8.2
43+
setup-method: ghcup
44+
allow-failure: false
45+
- compiler: ghc-9.6.6
46+
compilerKind: ghc
47+
compilerVersion: 9.6.6
48+
setup-method: ghcup
49+
allow-failure: false
50+
- compiler: ghc-9.4.8
51+
compilerKind: ghc
52+
compilerVersion: 9.4.8
53+
setup-method: ghcup
54+
allow-failure: false
55+
- compiler: ghc-9.2.8
56+
compilerKind: ghc
57+
compilerVersion: 9.2.8
58+
setup-method: ghcup
59+
allow-failure: false
60+
- compiler: ghc-9.0.2
61+
compilerKind: ghc
62+
compilerVersion: 9.0.2
63+
setup-method: ghcup
64+
allow-failure: false
65+
- compiler: ghc-8.10.7
66+
compilerKind: ghc
67+
compilerVersion: 8.10.7
68+
setup-method: ghcup
69+
allow-failure: false
70+
fail-fast: false
71+
steps:
72+
- name: apt
73+
run: |
74+
apt-get update
75+
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
76+
mkdir -p "$HOME/.ghcup/bin"
77+
curl -sL https://downloads.haskell.org/ghcup/0.1.30.0/x86_64-linux-ghcup-0.1.30.0 > "$HOME/.ghcup/bin/ghcup"
78+
chmod a+x "$HOME/.ghcup/bin/ghcup"
79+
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
80+
"$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
81+
env:
82+
HCKIND: ${{ matrix.compilerKind }}
83+
HCNAME: ${{ matrix.compiler }}
84+
HCVER: ${{ matrix.compilerVersion }}
85+
- name: Set PATH and environment variables
86+
run: |
87+
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
88+
echo "LANG=C.UTF-8" >> "$GITHUB_ENV"
89+
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
90+
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
91+
HCDIR=/opt/$HCKIND/$HCVER
92+
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
93+
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
94+
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
95+
echo "HC=$HC" >> "$GITHUB_ENV"
96+
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
97+
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
98+
echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
99+
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
100+
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
101+
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
102+
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
103+
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
104+
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
105+
echo "GHCJSARITH=0" >> "$GITHUB_ENV"
106+
env:
107+
HCKIND: ${{ matrix.compilerKind }}
108+
HCNAME: ${{ matrix.compiler }}
109+
HCVER: ${{ matrix.compilerVersion }}
110+
- name: env
111+
run: |
112+
env
113+
- name: write cabal config
114+
run: |
115+
mkdir -p $CABAL_DIR
116+
cat >> $CABAL_CONFIG <<EOF
117+
remote-build-reporting: anonymous
118+
write-ghc-environment-files: never
119+
remote-repo-cache: $CABAL_DIR/packages
120+
logs-dir: $CABAL_DIR/logs
121+
world-file: $CABAL_DIR/world
122+
extra-prog-path: $CABAL_DIR/bin
123+
symlink-bindir: $CABAL_DIR/bin
124+
installdir: $CABAL_DIR/bin
125+
build-summary: $CABAL_DIR/logs/build.log
126+
store-dir: $CABAL_DIR/store
127+
install-dirs user
128+
prefix: $CABAL_DIR
129+
repository hackage.haskell.org
130+
url: http://hackage.haskell.org/
131+
EOF
132+
cat >> $CABAL_CONFIG <<EOF
133+
program-default-options
134+
ghc-options: $GHCJOBS +RTS -M3G -RTS
135+
EOF
136+
cat $CABAL_CONFIG
137+
- name: versions
138+
run: |
139+
$HC --version || true
140+
$HC --print-project-git-commit-id || true
141+
$CABAL --version || true
142+
- name: update cabal index
143+
run: |
144+
$CABAL v2-update -v
145+
- name: install cabal-plan
146+
run: |
147+
mkdir -p $HOME/.cabal/bin
148+
curl -sL https://github.com/haskell-hvr/cabal-plan/releases/download/v0.7.3.0/cabal-plan-0.7.3.0-x86_64-linux.xz > cabal-plan.xz
149+
echo 'f62ccb2971567a5f638f2005ad3173dba14693a45154c1508645c52289714cb2 cabal-plan.xz' | sha256sum -c -
150+
xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan
151+
rm -f cabal-plan.xz
152+
chmod a+x $HOME/.cabal/bin/cabal-plan
153+
cabal-plan --version
154+
- name: checkout
155+
uses: actions/checkout@v4
156+
with:
157+
path: source
158+
- name: initial cabal.project for sdist
159+
run: |
160+
touch cabal.project
161+
echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project
162+
cat cabal.project
163+
- name: sdist
164+
run: |
165+
mkdir -p sdist
166+
$CABAL sdist all --output-dir $GITHUB_WORKSPACE/sdist
167+
- name: unpack
168+
run: |
169+
mkdir -p unpacked
170+
find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \;
171+
- name: generate cabal.project
172+
run: |
173+
PKGDIR_memory_cache="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/memory-cache-[0-9.]*')"
174+
echo "PKGDIR_memory_cache=${PKGDIR_memory_cache}" >> "$GITHUB_ENV"
175+
rm -f cabal.project cabal.project.local
176+
touch cabal.project
177+
touch cabal.project.local
178+
echo "packages: ${PKGDIR_memory_cache}" >> cabal.project
179+
echo "package memory-cache" >> cabal.project
180+
echo " ghc-options: -Werror=missing-methods" >> cabal.project
181+
cat >> cabal.project <<EOF
182+
EOF
183+
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(memory-cache)$/; }' >> cabal.project.local
184+
cat cabal.project
185+
cat cabal.project.local
186+
- name: dump install plan
187+
run: |
188+
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
189+
cabal-plan
190+
- name: restore cache
191+
uses: actions/cache/restore@v4
192+
with:
193+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
194+
path: ~/.cabal/store
195+
restore-keys: ${{ runner.os }}-${{ matrix.compiler }}-
196+
- name: install dependencies
197+
run: |
198+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all
199+
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all
200+
- name: build w/o tests
201+
run: |
202+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
203+
- name: build
204+
run: |
205+
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always
206+
- name: cabal check
207+
run: |
208+
cd ${PKGDIR_memory_cache} || false
209+
${CABAL} -vnormal check
210+
- name: haddock
211+
run: |
212+
$CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
213+
- name: unconstrained build
214+
run: |
215+
rm -f cabal.project.local
216+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
217+
- name: save cache
218+
uses: actions/cache/save@v4
219+
if: always()
220+
with:
221+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
222+
path: ~/.cabal/store

.github/workflows/hlint.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: HLint
2+
on: push
3+
4+
jobs:
5+
hlint:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
10+
- name: 'Set up HLint'
11+
uses: haskell-actions/hlint-setup@v2
12+
with:
13+
version: '3.8'
14+
15+
- name: 'Run HLint'
16+
uses: haskell-actions/hlint-run@v2
17+
with:
18+
path: .
19+
fail-on: warning

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*~
2+
*.swp
3+
dist-*
4+
dist
5+
.ghc.environment.*
6+
.stack-work/
7+
stack.yaml
8+
stack.yaml.lock
9+
cabal.project.local

.hlint.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# HLint configuration file
2+
# https://github.com/ndmitchell/hlint
3+
##########################
4+
5+
# Replace a $ b $ c with a . b $ c
6+
- group: {name: dollar, enabled: true}
7+
8+
- ignore: {name: "Functor law"}
9+
- ignore: {name: "Redundant do"}
10+
- ignore: {name: "Use <=<"}
11+
- ignore: {name: "Use camelCase"}
12+
13+
- warn: {lhs: fmap f $ g, rhs: f <$> g}
14+
- warn: {lhs: maybe x identity, rhs: fromMaybe x}
15+
- warn: {lhs: return, rhs: pure}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Revision history for memory-cache
2+
3+
## 1.0.0.0 -- YYYY-mm-dd
4+
5+
* Initial version.

LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Copyright (c) 2024, Scrive AB
2+
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above
11+
copyright notice, this list of conditions and the following
12+
disclaimer in the documentation and/or other materials provided
13+
with the distribution.
14+
15+
* Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived
17+
from this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

cabal.haskell-ci

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
branches: master
2+
tests: True

cabal.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: .

fourmolu.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Number of spaces per indentation step
2+
indentation: 2
3+
4+
# Max line length for automatic line breaking
5+
column-limit: none
6+
7+
# Styling of arrows in type signatures (choices: trailing, leading, or leading-args)
8+
function-arrows: leading
9+
10+
# How to place commas in multi-line lists, records, etc. (choices: leading or trailing)
11+
comma-style: leading
12+
13+
# Styling of import/export lists (choices: leading, trailing, or diff-friendly)
14+
import-export-style: leading
15+
16+
# Whether to full-indent or half-indent 'where' bindings past the preceding body
17+
indent-wheres: true
18+
19+
# Whether to leave a space before an opening record brace
20+
record-brace-space: true
21+
22+
# Number of spaces between top-level declarations
23+
newlines-between-decls: 1
24+
25+
# How to print Haddock comments (choices: single-line, multi-line, or multi-line-compact)
26+
haddock-style: single-line
27+
28+
# How to print module docstring
29+
haddock-style-module: null
30+
31+
# Styling of let blocks (choices: auto, inline, newline, or mixed)
32+
let-style: inline
33+
34+
# How to align the 'in' keyword with respect to the 'let' keyword (choices: left-align, right-align, or no-space)
35+
in-style: no-space
36+
37+
# Whether to put parentheses around a single constraint (choices: auto, always, or never)
38+
single-constraint-parens: never
39+
40+
# Whether to put parentheses around a single deriving class (choices: auto, always, or never)
41+
single-deriving-parens: always
42+
43+
# Output Unicode syntax (choices: detect, always, or never)
44+
unicode: never
45+
46+
# Give the programmer more choice on where to insert blank lines
47+
respectful: true
48+
49+
# Fixity information for operators
50+
fixities: []
51+
52+
# Module reexports Fourmolu should know about
53+
reexports: []

0 commit comments

Comments
 (0)