Compare commits

..

No commits in common. "30132088dfd495c651c693e9452495e93a91928b" and "9876e488c40f7c8cbeda55fe8ca11df0fb541fb7" have entirely different histories.

7 changed files with 26 additions and 32 deletions

View file

@ -11,7 +11,7 @@
};
outputs = { self, nixpkgs, flake-utils, pre-commit-hooks }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
@ -27,13 +27,13 @@
# Dependency overrides go here
};
packages.default = self.packages.${system}.${packageName};
defaultPackage = self.packages.${system}.${packageName};
apps = {
# run with: nix run #.hcat
hcat = {
type = "app";
program = "${self.packages.${system}.default}/bin/hcat";
program = "${self.defaultPackage.${system}}/bin/hcat";
};
# run with: nix run
@ -43,28 +43,25 @@
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
settings = { ormolu.defaultExtensions = [ "GHC2021" ]; };
tools.fourmolu = haskellPackages.fourmolu;
hooks = {
nixfmt.enable = true;
fourmolu.enable = true;
hpack.enable = true;
hlint.enable = true;
doctest = {
enable = false;
enable = true;
name = "Run documentation tests";
entry = "${haskellPackages.doctest}/bin/doctest src app";
entry = "doctest";
files = "\\.l?hs$";
pass_filenames = false;
};
};
};
};
devShells.default = haskellPackages.shellFor {
devShell = haskellPackages.shellFor {
inherit (self.checks.${system}.pre-commit-check) shellHook;
packages = p: [ self.packages.${system}.default ];
packages = p: [ self.defaultPackage.${system} ];
withHoogle = true;

View file

@ -1,2 +1 @@
haddock-style: single-line
indentation: 2

View file

@ -24,9 +24,9 @@ library
hs-source-dirs:
src
default-extensions:
GHC2021
BlockArguments
OverloadedStrings
ImportQualifiedPost
ghc-options: -Wall -Wunused-packages -fdefer-typed-holes
build-depends:
base >=4.13 && <5
@ -40,9 +40,9 @@ executable hcat
hs-source-dirs:
app
default-extensions:
GHC2021
BlockArguments
OverloadedStrings
ImportQualifiedPost
ghc-options: -Wall -Wunused-packages -fdefer-typed-holes
build-depends:
base >=4.13 && <5
@ -59,9 +59,9 @@ test-suite spec
hs-source-dirs:
test
default-extensions:
GHC2021
BlockArguments
OverloadedStrings
ImportQualifiedPost
ghc-options: -Wall -Wunused-packages -fdefer-typed-holes
cpp-options: -DTEST
build-tool-depends:
@ -74,4 +74,4 @@ test-suite spec
, quickcheck-instances
, quickcheck-text
, text
default-language: GHC2021
default-language: Haskell2010

View file

@ -23,9 +23,9 @@ ghc-options:
- -fdefer-typed-holes
default-extensions:
- GHC2021
- BlockArguments
- OverloadedStrings
- ImportQualifiedPost
library:
source-dirs: src
@ -54,5 +54,3 @@ tests:
- quickcheck-instances
- quickcheck-text
build-tools: hspec-discover
verbatim:
default-language: GHC2021

View file

@ -1,6 +1,6 @@
module HCat (
runHCat,
defaultMain,
runHCat,
defaultMain,
) where
import System.Environment qualified as Env
@ -15,16 +15,16 @@ import HCat.Internal (parseArgs)
runHCat :: IO ()
runHCat = do
fileNameOrError <- parseArgs <$> Env.getArgs
fileName <- eitherToError fileNameOrError
TextIO.readFile fileName >>= TextIO.putStr
fileNameOrError <- parseArgs <$> Env.getArgs
fileName <- eitherToError fileNameOrError
TextIO.readFile fileName >>= TextIO.putStr
eitherToError :: Show a => Either a b -> IO b
eitherToError = either (Exception.throwIO . IOError.userError . show) return
handleError :: IOError -> IO ()
handleError e = do
hPutStrLn stderr $ "I ran into an issue: " <> show e
hPutStrLn stderr $ "I ran into an issue: " <> show e
defaultMain :: IO ()
defaultMain = Exception.catch runHCat handleError

View file

@ -7,9 +7,9 @@ module HCat.Internal where
-- Right "foo"
parseArgs :: [String] -> Either String FilePath
parseArgs args = case args of
[] -> Left "No filename given!"
[arg] -> Right arg
_ -> Left "Only a single file is supported"
[] -> Left "No filename given!"
[arg] -> Right arg
_ -> Left "Only a single file is supported"
-- | @chunksOf n@ splits a list into chunks of at most @n@ items.
--
@ -24,7 +24,7 @@ parseArgs args = case args of
chunksOf :: Int -> [a] -> [[a]]
chunksOf _ [] = []
chunksOf n xs@(_ : _)
| n <= 0 = []
| otherwise =
let (chunk, rest) = splitAt n xs
in chunk : chunksOf n rest
| n <= 0 = []
| otherwise =
let (chunk, rest) = splitAt n xs
in chunk : chunksOf n rest

View file

@ -1,4 +1,4 @@
-- {-# LANGUAGE GHC2021 #-}
{-# LANGUAGE GHC2021 #-}
module HCatSpec (spec) where