Skip to content

Commit

Permalink
Merge pull request #58 from expipiplus1/joe-streamly
Browse files Browse the repository at this point in the history
Changes for streamly 0.8
  • Loading branch information
expipiplus1 authored Jul 20, 2021
2 parents 38c4a14 + 47e3bc3 commit ecdd507
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Revision history for nix-linter

## 0.2.0.4 -- 2021-07-20

* Changes for streamly 0.8

## 0.2.0.3 -- 2021-07-20

* Relax bounds on hnix
Expand Down
7 changes: 5 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ nixpkgsSrc ? builtins.fetchTarball {
url =
"https://github.com/NixOS/nixpkgs/archive/51bb9f3e9ab6161a3bf7746e20b955712cef618b.tar.gz"; # nixpkgs-unstable
sha256 = "1bqla14c80ani27c7901rnl37kiiqrvyixs6ifvm48p5y6xbv1p7";
"https://github.com/NixOS/nixpkgs/archive/38296d89d41c26a127b69c52421fbee95ceb0d22.tar.gz"; # haskell-updates
sha256 = "108c4wm4vfqkgd6awpaskakq26f8ajx729s4bxqvvvfflrzwrlrv";
}, pkgs ? import nixpkgsSrc { }, compiler ? null }:

let
Expand All @@ -12,5 +12,8 @@ let

in haskellPackages.developPackage {
name = "";
overrides = self: super: {
streamly = self.streamly_0_8_0;
};
root = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
}
15 changes: 7 additions & 8 deletions main/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Prelude hiding (log, readFile)
import Control.Arrow ((>>>))
import Control.Monad (join, when)
import Control.Monad.Trans (MonadIO, liftIO)
import Data.Foldable (for_)
import Data.Foldable (for_, traverse_)
import Data.Function ((&))
import Data.IORef
import Data.List (isSuffixOf, sortOn)
Expand All @@ -38,7 +38,6 @@ import Nix.Parser

import qualified Data.Set as Set

import Streamly
import Streamly.Prelude ((.:))
import qualified Streamly.Prelude as S

Expand Down Expand Up @@ -86,12 +85,12 @@ log :: Text -> IO ()
log = hPutStrLn stderr

-- Example from https://hackage.haskell.org/package/streamly
listDirRecursive :: (IsStream t, MonadIO m, MonadIO (t m), Monoid (t m FilePath)) => FilePath -> t m FilePath
listDirRecursive :: (S.IsStream t, MonadIO m, MonadIO (t m), Monoid (t m FilePath)) => FilePath -> t m FilePath
listDirRecursive path = resolveDir' path >>= readDir
where
readDir dir = do
(dirs, files) <- listDir dir
S.fromList (toFilePath <$> files) `serial` foldMap readDir dirs
S.fromList (toFilePath <$> files) `S.serial` foldMap readDir dirs

parseFiles = S.mapMaybeM $ (\path ->
parseNixFileLoc path >>= \case
Expand All @@ -102,7 +101,7 @@ parseFiles = S.mapMaybeM $ (\path ->
pure Nothing)

pipeline (NixLinter {..}) combined = let
exitLog x = S.yieldM . liftIO . const (log x >> exitFailure)
exitLog x = S.fromEffect . liftIO . const (log x >> exitFailure)
walker = if recursive
then (>>= listDirRecursive)
else id
Expand All @@ -117,8 +116,8 @@ pipeline (NixLinter {..}) combined = let
& walk
& S.filter ((recursive -->) <$> isSuffixOf ".nix")
& S.map (\p -> if p == "-" then "/dev/stdin" else p)
& aheadly . parseFiles
& aheadly . (S.map (combined >>> S.fromList) >>> join)
& S.fromAhead . parseFiles
& S.fromAhead . (S.map (combined >>> S.fromList) >>> join)

extraHelp :: OffenseCategory -> IO ()
extraHelp cat = do
Expand All @@ -137,7 +136,7 @@ runChecks (opts@NixLinter{..}) = do
for_ err (log . T.pack)
exitFailure
Right xs -> pure xs
mapM_ extraHelp (sortOn show cats)
traverse_ extraHelp (sortOn show cats)
exitSuccess

combined <- getCombined check
Expand Down
4 changes: 2 additions & 2 deletions nix-linter.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name: nix-linter
-- PVP summary: +-+------- breaking API changes
-- | | +----- non-breaking API additions
-- | | | +--- code changes with no API change
version: 0.2.0.3
version: 0.2.0.4

-- A short (one-line) description of the package.
synopsis: Linter for Nix(pkgs), based on hnix
Expand Down Expand Up @@ -94,7 +94,7 @@ executable nix-linter
nix-linter,

-- Packages only used here:
streamly >=0.5 && <0.8,
streamly >=0.8,
mtl >=1.1,
path-io >=1.4,
path >= 0.6,
Expand Down

0 comments on commit ecdd507

Please sign in to comment.