Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/cabal2nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: af7cf68dfc6f
Choose a base ref
...
head repository: NixOS/cabal2nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 379decf3fe0e
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Dec 21, 2018

  1. listDirectoryFilesBySuffix: simplify the implementation

    Match suffixes first, then do the I/O to see whether matching paths refers to a
    file or not. Ought to be more efficient. There's no point doing the I/O if the
    suffix doesn't match.
    peti committed Dec 21, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    shlevy Shea Levy
    Copy the full SHA
    7a72711 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    shlevy Shea Levy
    Copy the full SHA
    379decf View commit details
Showing with 7 additions and 14 deletions.
  1. +4 −3 cabal2nix.cabal
  2. +3 −11 test/Main.hs
7 changes: 4 additions & 3 deletions cabal2nix.cabal
Original file line number Diff line number Diff line change
@@ -200,6 +200,7 @@ test-suite regression-test
default-extensions: MonadFailDesugaring
build-tools: cabal2nix
ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates
-Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
-with-rtsopts=-K64K
-- TODO: this must be 1K!
-Wredundant-constraints -threaded -with-rtsopts=-K64K
-- TODO: This ought to be 1K! ^^^
-- https://github.com/NixOS/cabal2nix/issues/398
-- https://github.com/feuerbach/tasty/issues/234
14 changes: 3 additions & 11 deletions test/Main.hs
Original file line number Diff line number Diff line change
@@ -99,14 +99,6 @@ testExecutable exe cabalFile = do
-- * Helper functions
-------------------------------------------------------------------------------

-- | Find all *files* in the given directory. This function does not recurse,
-- nor does it include the special entries @'.'@ or @'..'@ in the result.

listDirectoryFiles :: FilePath -> IO [FilePath]
listDirectoryFiles dirPath = do
entries <- listDirectory dirPath
filterM doesFileExist (map (dirPath </>) entries)

-- | Find all *files* in the given directory that end with the given suffix.
-- This function does not recurse, nor does it include the special entries
-- @'.'@ or @'..'@ in the result.
@@ -119,9 +111,9 @@ listDirectoryFiles dirPath = do
-- we prefer our own simpler code.

listDirectoryFilesBySuffix :: String -> FilePath -> IO [FilePath]
listDirectoryFilesBySuffix suff =
fmap (filter ((suff ==) . takeExtension)) . listDirectoryFiles

listDirectoryFilesBySuffix suff dirPath = do
entries <- listDirectory dirPath
filterM doesFileExist [ dirPath </> e | e <- entries, takeExtension e == suff ]

-- | A variant of 'writeFile' that appends a newline to the end of the buffer
-- before writing.