From 68fac811f74356ee1e06b31c2ce95909b56f6381 Mon Sep 17 00:00:00 2001 From: Joris Dral Date: Wed, 17 Jul 2024 14:55:31 +0200 Subject: [PATCH 1/8] Remove CHaP package repository, remove redundant allow-newer --- cabal.project | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/cabal.project b/cabal.project index 5ab8103..54eae5f 100644 --- a/cabal.project +++ b/cabal.project @@ -1,20 +1,6 @@ --- Custom repository for cardano haskell packages -repository cardano-haskell-packages - url: https://input-output-hk.github.io/cardano-haskell-packages - secure: True - root-keys: - 3e0cce471cf09815f930210f7827266fd09045445d65923e6d0238a6cd15126f - 443abb7fb497a134c343faf52f0b659bd7999bc06b7f63fa76dc99d631f9bea1 - a86a1f6ce86c449c46666bda44268677abf29b5b2d2eb5ec7af903ec2f117a82 - bcec67e8e99cabfa7764d75ad9b158d72bfacf70ca1d0ec8bc6b4406d1bf8413 - c00aae8461a256275598500ea0e187588c35a5d5d7454fb57eac18d9edb86a56 - d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee - index-state: -- Bump this if you need newer packages from Hackage - , hackage.haskell.org 2024-06-07T00:00:00Z - -- Bump this if you need newer packages from CHaP - , cardano-haskell-packages 2024-06-07T00:00:00Z + , hackage.haskell.org 2024-07-17T00:00:00Z packages: fs-api @@ -26,8 +12,3 @@ benchmarks: True -- comment me if you are benchmarking import: cabal.project.debug - -if impl(ghc >=9.8) - allow-newer: - -- https://github.com/wrengr/unix-bytestring/pull/46 - , unix-bytestring:base From 86d76dbf8561d148e650b9c44956f27bc4da1acd Mon Sep 17 00:00:00 2001 From: Joris Dral Date: Wed, 17 Jul 2024 17:27:03 +0200 Subject: [PATCH 2/8] Tight dependency bounds --- fs-api/CHANGELOG.md | 1 + fs-api/fs-api.cabal | 22 +++++++++++----------- fs-sim/CHANGELOG.md | 1 + fs-sim/fs-sim.cabal | 18 +++++++++--------- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/fs-api/CHANGELOG.md b/fs-api/CHANGELOG.md index 41b170f..9e9b940 100644 --- a/fs-api/CHANGELOG.md +++ b/fs-api/CHANGELOG.md @@ -33,6 +33,7 @@ responsible for picking sensible directory/file names. * Bump upper version bounds for `io-classes` to `1.6` * Make it build with `ghc-9.10`. +* Tight dependency bounds. ## 0.2.0.1 -- 2023-10-30 diff --git a/fs-api/fs-api.cabal b/fs-api/fs-api.cabal index 94e0ade..5e28a2f 100644 --- a/fs-api/fs-api.cabal +++ b/fs-api/fs-api.cabal @@ -39,17 +39,17 @@ library default-language: Haskell2010 build-depends: - , base >=4.14 && <4.21 - , bytestring >=0.10 && <0.13 - , containers >=0.5 && <0.8 - , deepseq - , digest - , directory >=1.3 && <1.4 - , filepath >=1.4 && <1.6 - , io-classes >=0.3 && <1.6 + , base >=4.14 && <4.21 + , bytestring ^>=0.10 || ^>=0.11 || ^>=0.12 + , containers ^>=0.5 || ^>=0.6 || ^>=0.7 + , deepseq ^>=1.4 || ^>=1.5 + , digest ^>=0.0 + , directory ^>=1.3 + , filepath ^>=1.4 || ^>=1.5 + , io-classes ^>=1.0 || ^>=1.1 || ^>=1.2 || ^>=1.3 || ^>=1.4 || ^>=1.5 , primitive ^>=0.9 , safe-wild-cards ^>=1.0 - , text >=1.2 && <2.2 + , text ^>=1.2 || ^>=2.0 || ^>=2.1 if os(windows) hs-source-dirs: src-win32 @@ -61,8 +61,8 @@ library hs-source-dirs: src-unix exposed-modules: System.FS.IO.Unix build-depends: - , unix - , unix-bytestring >=0.4.0 + , unix ^>=2.7 || ^>=2.8 + , unix-bytestring ^>=0.4 ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns diff --git a/fs-sim/CHANGELOG.md b/fs-sim/CHANGELOG.md index 6d15f4a..08af8f3 100644 --- a/fs-sim/CHANGELOG.md +++ b/fs-sim/CHANGELOG.md @@ -34,6 +34,7 @@ * The shrinker for `Errors` was not shrinking every stream. * Adapt to moving of `Util` modules in `fs-api`. * Make it build with `ghc-9.10`. +* Tight dependency bounds. ## 0.2.1.1 -- 2023-10-30 diff --git a/fs-sim/fs-sim.cabal b/fs-sim/fs-sim.cabal index 0dc0a5e..5d0a19a 100644 --- a/fs-sim/fs-sim.cabal +++ b/fs-sim/fs-sim.cabal @@ -36,18 +36,18 @@ library other-modules: System.FS.Sim.Prim default-language: Haskell2010 build-depends: - , base >=4.14 && <4.21 - , base16-bytestring - , bytestring >=0.10 && <0.13 - , containers >=0.5 && <0.8 + , base >=4.14 && <4.21 + , base16-bytestring ^>=0.1 || ^>=1.0 + , bytestring ^>=0.10 || ^>=0.11 || ^>=0.12 + , containers ^>=0.5 || ^>=0.6 || ^>=0.7 , fs-api ^>=0.2 - , io-classes >=0.3 && <1.6 - , mtl + , io-classes ^>=1.0 || ^>=1.1 || ^>=1.2 || ^>=1.3 || ^>=1.4 || ^>=1.5 + , mtl ^>=2.2 || ^>=2.3 , primitive ^>=0.9 - , QuickCheck + , QuickCheck ^>=2.13 || ^>=2.14 || ^>=2.15 , safe-wild-cards ^>=1.0 - , strict-stm >=0.3 && <1.6 - , text >=1.2 && <2.2 + , strict-stm ^>=1.0 || ^>=1.1 || ^>=1.2 || ^>=1.3 || ^>=1.4 || ^>=1.5 + , text ^>=1.2 || ^>=2.0 || ^>=2.1 ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns From 3c738a369227acd55f9a67dcb0fd15d5a818145f Mon Sep 17 00:00:00 2001 From: Joris Dral Date: Wed, 17 Jul 2024 17:27:38 +0200 Subject: [PATCH 3/8] GHA cache hash now takes into account all cabal.project* files --- .github/workflows/haskell.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 325f009..5c7e1b5 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -57,9 +57,9 @@ jobs: cache-name: cache-cabal-build with: path: ${{ steps.setup-haskell.outputs.cabal-store }} - key: ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} + key: ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project*') }} restore-keys: | - ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} + ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project*') }} ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}- ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}- From 106d279c7859163a2b1efb3a049fb0f5847cfceb Mon Sep 17 00:00:00 2001 From: Joris Dral Date: Wed, 17 Jul 2024 17:29:39 +0200 Subject: [PATCH 4/8] Update GHC and Cabal versions in GHA workflow --- .github/workflows/documentation.yml | 4 ++-- .github/workflows/haskell.yml | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 7dcd910..4514b9d 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -32,8 +32,8 @@ jobs: fail-fast: false env: - ghc: "9.2.8" - cabal: "3.10.2.0" + ghc: "9.6.6" + cabal: "3.12.1.0" os: ubuntu-latest" steps: diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 5c7e1b5..072ec97 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -22,8 +22,8 @@ jobs: strategy: fail-fast: false matrix: - ghc: ["8.10.7", "9.2.8", "9.4.8", "9.6.4", "9.8.2", "9.10.1"] - cabal: ["3.10.3.0"] + ghc: ["8.10.7", "9.2.8", "9.4.8", "9.6.6", "9.8.2", "9.10.1"] + cabal: ["3.12.1.0"] os: [ubuntu-latest, windows-latest, macOS-13] timeout-minutes: 60 @@ -65,7 +65,7 @@ jobs: - name: Install cabal dependencies id: build-dependencies - run: cabal build --only-dependencies --enable-tests --enable-benchmarks all + run: cabal build --only-dependencies all - name: "Save cache" uses: actions/cache/save@v4 @@ -104,8 +104,8 @@ jobs: strategy: fail-fast: false matrix: - ghc: ["9.6.4"] - cabal: ["3.10.3.0"] + ghc: ["9.6.6"] + cabal: ["3.12.1.0"] os: [ubuntu-latest] # Fix the index-state so we can get proper caching effects. Change this to a @@ -171,8 +171,8 @@ jobs: strategy: fail-fast: false matrix: - ghc: ["9.6.4"] - cabal: ["3.10.3.0"] + ghc: ["9.6.6"] + cabal: ["3.12.1.0"] os: [ubuntu-latest] # See the comment on the hackage-index-state environment variable for the @@ -233,7 +233,7 @@ jobs: strategy: fail-fast: false matrix: - ghc: ["9.6.4"] + ghc: ["9.6.6"] cabal: ["3.10.3.0"] os: [ubuntu-latest] From 040015583b4b2b0375eb07ad5f7bb29470ba8025 Mon Sep 17 00:00:00 2001 From: Joris Dral Date: Wed, 17 Jul 2024 17:33:14 +0200 Subject: [PATCH 5/8] Documentation update for fs-api --- fs-api/README.md | 4 ++-- fs-api/fs-api.cabal | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs-api/README.md b/fs-api/README.md index d82dd3c..dc317a3 100644 --- a/fs-api/README.md +++ b/fs-api/README.md @@ -16,10 +16,10 @@ data HasFS m h = HasFS { Code that is written using this interface can be run against any implementation of a file system. The `System.FS.IO` module provides a function for initialising -a `HasFS` interface for the built-in filesystem. +a `HasFS` interface for the real filesystem. ```haskell -ioHasFS :: MonadIO m => MountPoint -> HasFS m HandleIO +ioHasFS :: (MonadIO m, PrimState IO ~ PrimState m) => MountPoint -> HasFS m HandleIO ``` Note that `ioHasFS` requires some context in the form of a `MountPoint`: the diff --git a/fs-api/fs-api.cabal b/fs-api/fs-api.cabal index 5e28a2f..db50cc2 100644 --- a/fs-api/fs-api.cabal +++ b/fs-api/fs-api.cabal @@ -1,8 +1,8 @@ cabal-version: 3.0 name: fs-api version: 0.2.0.1 -synopsis: API for file systems -description: API for file systems. +synopsis: Abstract interface for the file system +description: Abstract interface for the file system. license: Apache-2.0 license-files: LICENSE From ae2a18a226ba98dc2d20686fddab3ce6b90b6b08 Mon Sep 17 00:00:00 2001 From: Joris Dral Date: Wed, 17 Jul 2024 17:35:24 +0200 Subject: [PATCH 6/8] Run GHA without debug mode --- .github/workflows/haskell.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 072ec97..ce64642 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -25,6 +25,12 @@ jobs: ghc: ["8.10.7", "9.2.8", "9.4.8", "9.6.6", "9.8.2", "9.10.1"] cabal: ["3.12.1.0"] os: [ubuntu-latest, windows-latest, macOS-13] + no-debug: [""] + include: + - ghc: "9.6.6" + cabal: "3.12.1.0" + os: ubuntu-latest + no-debug: "no-debug" timeout-minutes: 60 @@ -45,6 +51,12 @@ jobs: cabal configure --enable-tests --enable-benchmark --ghc-options="-Werror" --ghc-options="-fno-ignore-asserts" cat cabal.project.local + - name: Configure the build (no-debug) + if: ${{ matrix.no-debug }} + run: | + echo "" > cabal.project.debug + cat cabal.project.debug + - name: Record cabal dependencies id: record-deps run: | From 7a4e0bcebceb31ead31f4123f3a6ba465cf81a9a Mon Sep 17 00:00:00 2001 From: Joris Dral Date: Wed, 17 Jul 2024 17:57:59 +0200 Subject: [PATCH 7/8] Expose the `System.FS.Sim.Prim` module --- fs-sim/CHANGELOG.md | 1 + fs-sim/fs-sim.cabal | 15 +++------------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/fs-sim/CHANGELOG.md b/fs-sim/CHANGELOG.md index 08af8f3..f075ccd 100644 --- a/fs-sim/CHANGELOG.md +++ b/fs-sim/CHANGELOG.md @@ -25,6 +25,7 @@ * New constructors for the `Errors` type: `hGetBufSomeE`, `hGetBufSomeAtE`, `hGetBufSomeE`, and `hPutBufSomeAtE`. +* Expose the new `System.FS.Sim.Prim` module. ### Patch diff --git a/fs-sim/fs-sim.cabal b/fs-sim/fs-sim.cabal index 5d0a19a..bae10e0 100644 --- a/fs-sim/fs-sim.cabal +++ b/fs-sim/fs-sim.cabal @@ -30,10 +30,10 @@ library System.FS.Sim.Error System.FS.Sim.FsTree System.FS.Sim.MockFS + System.FS.Sim.Prim System.FS.Sim.STM System.FS.Sim.Stream - other-modules: System.FS.Sim.Prim default-language: Haskell2010 build-depends: , base >=4.14 && <4.21 @@ -56,15 +56,9 @@ library test-suite fs-sim-test type: exitcode-stdio-1.0 - hs-source-dirs: test src + hs-source-dirs: test main-is: Main.hs other-modules: - System.FS.Sim.Error - System.FS.Sim.FsTree - System.FS.Sim.MockFS - System.FS.Sim.Prim - System.FS.Sim.STM - System.FS.Sim.Stream Test.System.FS.Sim.Error Test.System.FS.Sim.FsTree Test.System.FS.StateMachine @@ -75,20 +69,17 @@ test-suite fs-sim-test default-language: Haskell2010 build-depends: , base - , base16-bytestring , bifunctors , bytestring , containers , fs-api + , fs-sim , generics-sop - , io-classes - , mtl , pretty-show , primitive , QuickCheck , quickcheck-state-machine >=0.10 , random - , safe-wild-cards , strict-stm , tasty , tasty-hunit From 7e2f38fb5fe3816e7c8c8b10081ef9520cddf94a Mon Sep 17 00:00:00 2001 From: Joris Dral Date: Wed, 17 Jul 2024 17:58:27 +0200 Subject: [PATCH 8/8] Rename `mkSimErrorHasFS` to `simErrorHasFS` --- fs-sim/CHANGELOG.md | 2 ++ fs-sim/src/System/FS/Sim/Error.hs | 23 +++++++++++------------ fs-sim/src/System/FS/Sim/MockFS.hs | 3 +-- fs-sim/src/System/FS/Sim/Prim.hs | 2 +- fs-sim/test/Test/System/FS/Sim/Error.hs | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/fs-sim/CHANGELOG.md b/fs-sim/CHANGELOG.md index f075ccd..e8741aa 100644 --- a/fs-sim/CHANGELOG.md +++ b/fs-sim/CHANGELOG.md @@ -20,6 +20,8 @@ breaking changes: * Add a `PrimMonad m` constraint to `runSimErrorFS`, `mkSimErrorHasFS'` and `mkSimErrorHasFS`. * Change the `StrictTVar` argument to `mkSimErrorHasFS` to a `StrictTMVar`. +* Rename `mkSimErrorHasFS` to `simErrorHasFS`. +* Rename `mkSimErrorHasFS'` to `simErrorHasFS'`. ### Non-breaking diff --git a/fs-sim/src/System/FS/Sim/Error.hs b/fs-sim/src/System/FS/Sim/Error.hs index 8fa802d..cbf8bff 100644 --- a/fs-sim/src/System/FS/Sim/Error.hs +++ b/fs-sim/src/System/FS/Sim/Error.hs @@ -10,8 +10,8 @@ -- testing error handling. module System.FS.Sim.Error ( -- * Simulate Errors monad - mkSimErrorHasFS - , mkSimErrorHasFS' + simErrorHasFS + , simErrorHasFS' , runSimErrorFS , withErrors -- * Streams @@ -481,22 +481,21 @@ instance Arbitrary Errors where Simulate Errors monad -------------------------------------------------------------------------------} --- | Alternative to 'mkSimErrorHasFS' that creates 'TVar's internally. -mkSimErrorHasFS' :: (MonadSTM m, MonadThrow m, PrimMonad m) +-- | Alternative to 'simErrorHasFS' that creates 'TVar's internally. +simErrorHasFS' :: (MonadSTM m, MonadThrow m, PrimMonad m) => MockFS -> Errors -> m (HasFS m HandleMock) -mkSimErrorHasFS' mockFS errs = - mkSimErrorHasFS <$> newTMVarIO mockFS <*> newTVarIO errs +simErrorHasFS' mockFS errs = + simErrorHasFS <$> newTMVarIO mockFS <*> newTVarIO errs -- | Introduce possibility of errors --- --- TODO: Lenses would be nice for the setters -mkSimErrorHasFS :: forall m. (MonadSTM m, MonadThrow m, PrimMonad m) +simErrorHasFS :: forall m. (MonadSTM m, MonadThrow m, PrimMonad m) => StrictTMVar m MockFS -> StrictTVar m Errors -> HasFS m HandleMock -mkSimErrorHasFS fsVar errorsVar = +simErrorHasFS fsVar errorsVar = + -- TODO: Lenses would be nice for the setters case Sim.simHasFS fsVar of hfs@HasFS{..} -> HasFS{ dumpState = @@ -547,7 +546,7 @@ mkSimErrorHasFS fsVar errorsVar = withErr errorsVar p1 (renameFile p1 p2) "renameFile" renameFileE (\e es -> es { renameFileE = e }) , mkFsErrorPath = fsToFsErrorPathUnmounted - , unsafeToFilePath = error "mkSimErrorHasFS:unsafeToFilePath" + , unsafeToFilePath = error "simErrorHasFS:unsafeToFilePath" -- File I\/O with user-supplied buffers , hGetBufSome = hGetBufSomeWithErr errorsVar hfs , hGetBufSomeAt = hGetBufSomeAtWithErr errorsVar hfs @@ -565,7 +564,7 @@ runSimErrorFS :: (MonadSTM m, MonadThrow m, PrimMonad m) runSimErrorFS mockFS errors action = do fsVar <- newTMVarIO mockFS errorsVar <- newTVarIO errors - a <- action errorsVar $ mkSimErrorHasFS fsVar errorsVar + a <- action errorsVar $ simErrorHasFS fsVar errorsVar fs' <- atomically $ takeTMVar fsVar return (a, fs') diff --git a/fs-sim/src/System/FS/Sim/MockFS.hs b/fs-sim/src/System/FS/Sim/MockFS.hs index bb50e90..8687d51 100644 --- a/fs-sim/src/System/FS/Sim/MockFS.hs +++ b/fs-sim/src/System/FS/Sim/MockFS.hs @@ -859,9 +859,8 @@ renameFile fpOld fpNew = -------------------------------------------------------------------------------} -- | Renders the 'MockFS' in a human-readable fashion. --- --- TODO: Right now does this not show the state of the handles. pretty :: MockFS -> String +-- TODO: Right now does this not show the state of the handles. pretty = FS.pretty renderFile . mockFiles where renderFile :: ByteString -> String diff --git a/fs-sim/src/System/FS/Sim/Prim.hs b/fs-sim/src/System/FS/Sim/Prim.hs index 23c2988..0bb981f 100644 --- a/fs-sim/src/System/FS/Sim/Prim.hs +++ b/fs-sim/src/System/FS/Sim/Prim.hs @@ -42,7 +42,7 @@ runFSSimT act !st = runExceptT $ flip runStateT st $ unFSSimT act -- -- This implementation runs in a primitive monad @m@ extended with an 'FSSimT' -- monad transformer. It is recommended to use 'System.FS.Sim.STM.simHasFS' or --- 'System.FS.Sim.Error.mkSimErrorHasFS' instead because they hide the monad +-- 'System.FS.Sim.Error.simErrorHasFS' instead because they hide the monad -- transformer. The caveat is that @m@ should be IO-like. primHasMockFS :: PrimMonad m => HasFS (FSSimT m) Mock.HandleMock -- An alternative design could have fixed this implementation to diff --git a/fs-sim/test/Test/System/FS/Sim/Error.hs b/fs-sim/test/Test/System/FS/Sim/Error.hs index 0a07b3b..5964254 100644 --- a/fs-sim/test/Test/System/FS/Sim/Error.hs +++ b/fs-sim/test/Test/System/FS/Sim/Error.hs @@ -175,7 +175,7 @@ propPutterPutsAll getCounter put toInput (SometimesPartialWrites errStream) bs = fsVar <- newTMVarIO MockFS.empty errVar <- newTVarIO onlyPutErrors counters <- zeroEntryCounters - let hfs = withEntryCounters counters $ mkSimErrorHasFS fsVar errVar + let hfs = withEntryCounters counters $ simErrorHasFS fsVar errVar withFile hfs (mkFsPath ["file1"]) (ReadWriteMode MustBeNew) $ \h -> do inp <- toInput bs n' <- put hfs h inp @@ -222,7 +222,7 @@ propGetterGetsAll getCounter get fromOutput (SometimesPartialReads errStream) bs fsVar <- newTMVarIO MockFS.empty errVar <- newTVarIO onlyGetErrors counters <- zeroEntryCounters - let hfs = withEntryCounters counters $ mkSimErrorHasFS fsVar errVar + let hfs = withEntryCounters counters $ simErrorHasFS fsVar errVar withFile hfs (mkFsPath ["file1"]) (ReadWriteMode MustBeNew) $ \h -> do n' <- Strict.hPutAllStrict hfs h bs let n = fromIntegral $ BS.length bs