Skip to content

Commit 7e2f38f

Browse files
committed
Rename mkSimErrorHasFS to simErrorHasFS
1 parent 7a4e0bc commit 7e2f38f

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

fs-sim/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
breaking changes:
2121
* Add a `PrimMonad m` constraint to `runSimErrorFS`, `mkSimErrorHasFS'` and `mkSimErrorHasFS`.
2222
* Change the `StrictTVar` argument to `mkSimErrorHasFS` to a `StrictTMVar`.
23+
* Rename `mkSimErrorHasFS` to `simErrorHasFS`.
24+
* Rename `mkSimErrorHasFS'` to `simErrorHasFS'`.
2325

2426
### Non-breaking
2527

fs-sim/src/System/FS/Sim/Error.hs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
-- testing error handling.
1111
module System.FS.Sim.Error (
1212
-- * Simulate Errors monad
13-
mkSimErrorHasFS
14-
, mkSimErrorHasFS'
13+
simErrorHasFS
14+
, simErrorHasFS'
1515
, runSimErrorFS
1616
, withErrors
1717
-- * Streams
@@ -481,22 +481,21 @@ instance Arbitrary Errors where
481481
Simulate Errors monad
482482
-------------------------------------------------------------------------------}
483483

484-
-- | Alternative to 'mkSimErrorHasFS' that creates 'TVar's internally.
485-
mkSimErrorHasFS' :: (MonadSTM m, MonadThrow m, PrimMonad m)
484+
-- | Alternative to 'simErrorHasFS' that creates 'TVar's internally.
485+
simErrorHasFS' :: (MonadSTM m, MonadThrow m, PrimMonad m)
486486
=> MockFS
487487
-> Errors
488488
-> m (HasFS m HandleMock)
489-
mkSimErrorHasFS' mockFS errs =
490-
mkSimErrorHasFS <$> newTMVarIO mockFS <*> newTVarIO errs
489+
simErrorHasFS' mockFS errs =
490+
simErrorHasFS <$> newTMVarIO mockFS <*> newTVarIO errs
491491

492492
-- | Introduce possibility of errors
493-
--
494-
-- TODO: Lenses would be nice for the setters
495-
mkSimErrorHasFS :: forall m. (MonadSTM m, MonadThrow m, PrimMonad m)
493+
simErrorHasFS :: forall m. (MonadSTM m, MonadThrow m, PrimMonad m)
496494
=> StrictTMVar m MockFS
497495
-> StrictTVar m Errors
498496
-> HasFS m HandleMock
499-
mkSimErrorHasFS fsVar errorsVar =
497+
simErrorHasFS fsVar errorsVar =
498+
-- TODO: Lenses would be nice for the setters
500499
case Sim.simHasFS fsVar of
501500
hfs@HasFS{..} -> HasFS{
502501
dumpState =
@@ -547,7 +546,7 @@ mkSimErrorHasFS fsVar errorsVar =
547546
withErr errorsVar p1 (renameFile p1 p2) "renameFile"
548547
renameFileE (\e es -> es { renameFileE = e })
549548
, mkFsErrorPath = fsToFsErrorPathUnmounted
550-
, unsafeToFilePath = error "mkSimErrorHasFS:unsafeToFilePath"
549+
, unsafeToFilePath = error "simErrorHasFS:unsafeToFilePath"
551550
-- File I\/O with user-supplied buffers
552551
, hGetBufSome = hGetBufSomeWithErr errorsVar hfs
553552
, hGetBufSomeAt = hGetBufSomeAtWithErr errorsVar hfs
@@ -565,7 +564,7 @@ runSimErrorFS :: (MonadSTM m, MonadThrow m, PrimMonad m)
565564
runSimErrorFS mockFS errors action = do
566565
fsVar <- newTMVarIO mockFS
567566
errorsVar <- newTVarIO errors
568-
a <- action errorsVar $ mkSimErrorHasFS fsVar errorsVar
567+
a <- action errorsVar $ simErrorHasFS fsVar errorsVar
569568
fs' <- atomically $ takeTMVar fsVar
570569
return (a, fs')
571570

fs-sim/src/System/FS/Sim/MockFS.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,9 +859,8 @@ renameFile fpOld fpNew =
859859
-------------------------------------------------------------------------------}
860860

861861
-- | Renders the 'MockFS' in a human-readable fashion.
862-
--
863-
-- TODO: Right now does this not show the state of the handles.
864862
pretty :: MockFS -> String
863+
-- TODO: Right now does this not show the state of the handles.
865864
pretty = FS.pretty renderFile . mockFiles
866865
where
867866
renderFile :: ByteString -> String

fs-sim/src/System/FS/Sim/Prim.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ runFSSimT act !st = runExceptT $ flip runStateT st $ unFSSimT act
4242
--
4343
-- This implementation runs in a primitive monad @m@ extended with an 'FSSimT'
4444
-- monad transformer. It is recommended to use 'System.FS.Sim.STM.simHasFS' or
45-
-- 'System.FS.Sim.Error.mkSimErrorHasFS' instead because they hide the monad
45+
-- 'System.FS.Sim.Error.simErrorHasFS' instead because they hide the monad
4646
-- transformer. The caveat is that @m@ should be IO-like.
4747
primHasMockFS :: PrimMonad m => HasFS (FSSimT m) Mock.HandleMock
4848
-- An alternative design could have fixed this implementation to

fs-sim/test/Test/System/FS/Sim/Error.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ propPutterPutsAll getCounter put toInput (SometimesPartialWrites errStream) bs =
175175
fsVar <- newTMVarIO MockFS.empty
176176
errVar <- newTVarIO onlyPutErrors
177177
counters <- zeroEntryCounters
178-
let hfs = withEntryCounters counters $ mkSimErrorHasFS fsVar errVar
178+
let hfs = withEntryCounters counters $ simErrorHasFS fsVar errVar
179179
withFile hfs (mkFsPath ["file1"]) (ReadWriteMode MustBeNew) $ \h -> do
180180
inp <- toInput bs
181181
n' <- put hfs h inp
@@ -222,7 +222,7 @@ propGetterGetsAll getCounter get fromOutput (SometimesPartialReads errStream) bs
222222
fsVar <- newTMVarIO MockFS.empty
223223
errVar <- newTVarIO onlyGetErrors
224224
counters <- zeroEntryCounters
225-
let hfs = withEntryCounters counters $ mkSimErrorHasFS fsVar errVar
225+
let hfs = withEntryCounters counters $ simErrorHasFS fsVar errVar
226226
withFile hfs (mkFsPath ["file1"]) (ReadWriteMode MustBeNew) $ \h -> do
227227
n' <- Strict.hPutAllStrict hfs h bs
228228
let n = fromIntegral $ BS.length bs

0 commit comments

Comments
 (0)