Skip to content

Commit

Permalink
Print Linter not found message in red
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhijit Sarkar committed Jan 2, 2025
1 parent ae327f0 commit bef5ad2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
7 changes: 5 additions & 2 deletions .github/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ if (( no_test == 0 )); then
fi

if (( no_lint == 0 )); then
red=$(tput -Txterm-256color setaf 1)
default=$(tput -Txterm-256color sgr0)

if [[ -x "$(command -v hlint)" ]]; then
hlint .
else
printf "hlint not found"
printf "%bhlint not found%b\n" "$red" "$default"
fi

ormolu_mode="check"
Expand All @@ -63,6 +66,6 @@ if (( no_lint == 0 )); then
if [[ -x "$(command -v ormolu)" ]]; then
ormolu -m "$ormolu_mode" $(find . -type f -name '*.hs')
else
printf "ormolu not found"
printf "%bormolu not found%b\n" "$red" "$default"
fi
fi
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: 'Install Stack'
uses: haskell-actions/setup@v2
Expand All @@ -17,7 +17,7 @@ jobs:
uses: haskell-actions/hlint-setup@v2

- name: 'Check Formatting'
uses: haskell-actions/run-ormolu@v14
uses: haskell-actions/run-ormolu@v16
with:
mode: check

Expand Down
4 changes: 2 additions & 2 deletions ninety-nine-haskell.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.12

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

Expand All @@ -10,7 +10,7 @@ description: Please see the README on GitHub at <https://github.com/asarkar/9
homepage: https://github.com/asarkar/99-haskell#readme
bug-reports: https://github.com/asarkar/99-haskell/issues
author: Abhijit Sarkar
maintainer: [email protected]
maintainer: Abhijit Sarkar
copyright: 2023 Abhijit Sarkar
license: Apache-2.0
license-file: LICENSE
Expand Down
24 changes: 12 additions & 12 deletions src/Arithmetic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ primesR a b = if a < 3 then 2 : xs else xs
True
(o, b) -- bounds of the array
[ (i, ()) -- association list
| p <- [3, 5 .. r],
-- Flip every multiple of an odd to False.
let q = p * p
s = 2 * p
-- Difference between divMod and quotRem.
-- https://stackoverflow.com/a/339823/839733
(n, x) = quotRem (o - q) s
q2 = if o <= q then q else q + (n + signum x) * s,
i <- [q2, q2 + s .. b]
| p <- [3, 5 .. r],
-- Flip every multiple of an odd to False.
let q = p * p
s = 2 * p
-- Difference between divMod and quotRem.
-- https://stackoverflow.com/a/339823/839733
(n, x) = quotRem (o - q) s
q2 = if o <= q then q else q + (n + signum x) * s,
i <- [q2, q2 + s .. b]
]

{-
Expand All @@ -168,9 +168,9 @@ goldbach :: Int -> (Int, Int)
goldbach n =
head
[ (x, y)
| x <- primesR 2 (n - 2),
let y = n - x,
isPrime y
| x <- primesR 2 (n - 2),
let y = n - x,
isPrime y
]

{-
Expand Down
8 changes: 4 additions & 4 deletions src/Misc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ knightsTour n isDone = go Set.empty
ys = L.find (not . null) $ map (go (Set.insert pos visited)) nexts
moves (i, j) =
[ (i', j')
| (dx, dy) <- [(1, 2), (2, 1)],
i' <- [i + dx, i - dx],
j' <- [j + dy, j - dy],
Ix.inRange ((1, 1), (n, n)) (i', j')
| (dx, dy) <- [(1, 2), (2, 1)],
i' <- [i + dx, i - dx],
j' <- [j + dy, j - dy],
Ix.inRange ((1, 1), (n, n)) (i', j')
]

{-
Expand Down

0 comments on commit bef5ad2

Please sign in to comment.