Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for Hackage #76

Merged
merged 8 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
32 changes: 22 additions & 10 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ 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]
no-debug: [""]
include:
- ghc: "9.6.6"
cabal: "3.12.1.0"
os: ubuntu-latest
no-debug: "no-debug"

timeout-minutes: 60

Expand All @@ -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: |
Expand All @@ -57,15 +69,15 @@ 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 }}-

- 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
Expand Down Expand Up @@ -104,8 +116,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
Expand Down Expand Up @@ -171,8 +183,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
Expand Down Expand Up @@ -233,7 +245,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: ["9.6.4"]
ghc: ["9.6.6"]
cabal: ["3.10.3.0"]
os: [ubuntu-latest]

Expand Down
21 changes: 1 addition & 20 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions fs-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions fs-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions fs-api/fs-api.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions fs-sim/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
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

* New constructors for the `Errors` type: `hGetBufSomeE`, `hGetBufSomeAtE`,
`hGetBufSomeE`, and `hPutBufSomeAtE`.
* Expose the new `System.FS.Sim.Prim` module.

### Patch

Expand All @@ -34,6 +37,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

Expand Down
33 changes: 12 additions & 21 deletions fs-sim/fs-sim.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ 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
, 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
Expand All @@ -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
Expand All @@ -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
Expand Down
23 changes: 11 additions & 12 deletions fs-sim/src/System/FS/Sim/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
-- testing error handling.
module System.FS.Sim.Error (
-- * Simulate Errors monad
mkSimErrorHasFS
, mkSimErrorHasFS'
simErrorHasFS
, simErrorHasFS'
, runSimErrorFS
, withErrors
-- * Streams
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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
Expand All @@ -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')

Expand Down
3 changes: 1 addition & 2 deletions fs-sim/src/System/FS/Sim/MockFS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fs-sim/src/System/FS/Sim/Prim.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions fs-sim/test/Test/System/FS/Sim/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down