Skip to content

Commit bef5ad2

Browse files
author
Abhijit Sarkar
committed
Print Linter not found message in red
1 parent ae327f0 commit bef5ad2

File tree

5 files changed

+25
-22
lines changed

5 files changed

+25
-22
lines changed

.github/run.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ if (( no_test == 0 )); then
4949
fi
5050

5151
if (( no_lint == 0 )); then
52+
red=$(tput -Txterm-256color setaf 1)
53+
default=$(tput -Txterm-256color sgr0)
54+
5255
if [[ -x "$(command -v hlint)" ]]; then
5356
hlint .
5457
else
55-
printf "hlint not found"
58+
printf "%bhlint not found%b\n" "$red" "$default"
5659
fi
5760

5861
ormolu_mode="check"
@@ -63,6 +66,6 @@ if (( no_lint == 0 )); then
6366
if [[ -x "$(command -v ormolu)" ]]; then
6467
ormolu -m "$ormolu_mode" $(find . -type f -name '*.hs')
6568
else
66-
printf "ormolu not found"
69+
printf "%bormolu not found%b\n" "$red" "$default"
6770
fi
6871
fi

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
build-and-test:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v3
9+
- uses: actions/checkout@v4
1010

1111
- name: 'Install Stack'
1212
uses: haskell-actions/setup@v2
@@ -17,7 +17,7 @@ jobs:
1717
uses: haskell-actions/hlint-setup@v2
1818

1919
- name: 'Check Formatting'
20-
uses: haskell-actions/run-ormolu@v14
20+
uses: haskell-actions/run-ormolu@v16
2121
with:
2222
mode: check
2323

ninety-nine-haskell.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 1.12
22

3-
-- This file has been generated from package.yaml by hpack version 0.36.0.
3+
-- This file has been generated from package.yaml by hpack version 0.37.0.
44
--
55
-- see: https://github.com/sol/hpack
66

@@ -10,7 +10,7 @@ description: Please see the README on GitHub at <https://github.com/asarkar/9
1010
homepage: https://github.com/asarkar/99-haskell#readme
1111
bug-reports: https://github.com/asarkar/99-haskell/issues
1212
author: Abhijit Sarkar
13-
maintainer: [email protected]
13+
maintainer: Abhijit Sarkar
1414
copyright: 2023 Abhijit Sarkar
1515
license: Apache-2.0
1616
license-file: LICENSE

src/Arithmetic.hs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,15 @@ primesR a b = if a < 3 then 2 : xs else xs
147147
True
148148
(o, b) -- bounds of the array
149149
[ (i, ()) -- association list
150-
| p <- [3, 5 .. r],
151-
-- Flip every multiple of an odd to False.
152-
let q = p * p
153-
s = 2 * p
154-
-- Difference between divMod and quotRem.
155-
-- https://stackoverflow.com/a/339823/839733
156-
(n, x) = quotRem (o - q) s
157-
q2 = if o <= q then q else q + (n + signum x) * s,
158-
i <- [q2, q2 + s .. b]
150+
| p <- [3, 5 .. r],
151+
-- Flip every multiple of an odd to False.
152+
let q = p * p
153+
s = 2 * p
154+
-- Difference between divMod and quotRem.
155+
-- https://stackoverflow.com/a/339823/839733
156+
(n, x) = quotRem (o - q) s
157+
q2 = if o <= q then q else q + (n + signum x) * s,
158+
i <- [q2, q2 + s .. b]
159159
]
160160

161161
{-
@@ -168,9 +168,9 @@ goldbach :: Int -> (Int, Int)
168168
goldbach n =
169169
head
170170
[ (x, y)
171-
| x <- primesR 2 (n - 2),
172-
let y = n - x,
173-
isPrime y
171+
| x <- primesR 2 (n - 2),
172+
let y = n - x,
173+
isPrime y
174174
]
175175

176176
{-

src/Misc.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ knightsTour n isDone = go Set.empty
6262
ys = L.find (not . null) $ map (go (Set.insert pos visited)) nexts
6363
moves (i, j) =
6464
[ (i', j')
65-
| (dx, dy) <- [(1, 2), (2, 1)],
66-
i' <- [i + dx, i - dx],
67-
j' <- [j + dy, j - dy],
68-
Ix.inRange ((1, 1), (n, n)) (i', j')
65+
| (dx, dy) <- [(1, 2), (2, 1)],
66+
i' <- [i + dx, i - dx],
67+
j' <- [j + dy, j - dy],
68+
Ix.inRange ((1, 1), (n, n)) (i', j')
6969
]
7070

7171
{-

0 commit comments

Comments
 (0)