Skip to content

Commit 568698a

Browse files
committed
fixup! fixup! io-sim: Add support for unique symbol generation
1 parent f952e58 commit 568698a

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

io-sim/src/Control/Monad/IOSim.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module Control.Monad.IOSim
4848
, ThreadLabel
4949
, IOSimThreadId (..)
5050
, Labelled (..)
51-
, IOSimUnique
51+
, Unique
5252
-- ** Dynamic Tracing
5353
, traceM
5454
, traceSTM

io-sim/src/Control/Monad/IOSim/CommonTypes.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module Control.Monad.IOSim.CommonTypes
2929
, BlockedReason (..)
3030
, Labelled (..)
3131
, ppLabelled
32-
, IOSimUnique(..)
32+
, Unique (..)
3333
-- * Utils
3434
, ppList
3535
) where
@@ -205,10 +205,10 @@ ppLabelled pp Labelled { l_labelled = a, l_label = Nothing } = pp a
205205
ppLabelled pp Labelled { l_labelled = a, l_label = Just lbl } = concat ["Labelled ", pp a, " ", lbl]
206206

207207
-- | Abstract unique symbols à la "Data.Unique".
208-
newtype IOSimUnique s = MkUnique{ unMkUnique :: Integer }
208+
newtype Unique s = MkUnique{ unMkUnique :: Integer }
209209
deriving stock (Eq, Ord)
210210
deriving newtype (Hashable, NFData)
211-
type role IOSimUnique nominal
211+
type role Unique nominal
212212

213213
--
214214
-- Utils

io-sim/src/Control/Monad/IOSim/Internal.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ data SimState s a = SimState {
144144
clocks :: !(Map ClockId UTCTime),
145145
nextVid :: !VarId, -- ^ next unused 'VarId'
146146
nextTmid :: !TimeoutId, -- ^ next unused 'TimeoutId'
147-
nextUniq :: !(IOSimUnique s) -- ^ next unused @'IOSimUnique' s@
147+
nextUniq :: !(Unique s) -- ^ next unused @'Unique' s@
148148
}
149149

150150
initialState :: SimState s a

io-sim/src/Control/Monad/IOSim/Types.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ import Control.Monad.Fail qualified as Fail
105105
import Data.Bifoldable
106106
import Data.Bifunctor (bimap)
107107
import Data.Dynamic (Dynamic, toDyn)
108-
import Data.Hashable (Hashable(hash))
109108
import Data.List.Trace qualified as Trace
110109
import Data.Map.Strict (Map)
111110
import Data.Maybe (fromMaybe)
@@ -124,6 +123,7 @@ import GHC.Generics (Generic)
124123
import Quiet (Quiet (..))
125124

126125
import Control.Monad.IOSim.CommonTypes
126+
import Control.Monad.IOSim.CommonTypes qualified as Sim
127127
import Control.Monad.IOSim.STM
128128
import Control.Monad.IOSimPOR.Types
129129

@@ -195,7 +195,7 @@ data SimA s a where
195195
ExploreRaces :: SimA s b -> SimA s b
196196

197197
Fix :: (x -> IOSim s x) -> (x -> SimA s r) -> SimA s r
198-
NewUnique :: (IOSimUnique s -> SimA s r) -> SimA s r
198+
NewUnique :: (Sim.Unique s -> SimA s r) -> SimA s r
199199

200200

201201
newtype STM s a = STM { unSTM :: forall r. (a -> StmA s r) -> StmA s r }
@@ -630,9 +630,9 @@ instance MonadLabelledMVar (IOSim s) where
630630
labelMVar = labelMVarDefault
631631

632632
instance MonadUnique (IOSim s) where
633-
type Unique (IOSim s) = IOSimUnique s
633+
type Unique (IOSim s) = Sim.Unique s
634634
newUnique = IOSim (oneShot NewUnique)
635-
hashUnique = hash
635+
hashUnique = fromInteger . unMkUnique
636636

637637
data Async s a = Async !IOSimThreadId (STM s (Either SomeException a))
638638

@@ -1065,7 +1065,7 @@ data SimEventType
10651065
-- ^ thread terminated by an unhandled exception
10661066

10671067
| EventUniqueCreated Integer
1068-
-- ^ created the n-th 'IOSimUnique'
1068+
-- ^ created the n-th 'Unique'
10691069

10701070
--
10711071
-- STM events

io-sim/src/Control/Monad/IOSimPOR/Internal.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ data SimState s a = SimState {
200200
nextTmid :: !TimeoutId, -- ^ next unused 'TimeoutId'
201201
-- | previous steps (which we may race with).
202202
-- Note this is *lazy*, so that we don't compute races we will not reverse.
203-
nextUniq :: !(IOSimUnique s), -- ^ next unused @'IOSimUnique' s@
203+
nextUniq :: !(Unique s), -- ^ next unused @'Unique' s@
204204
races :: Races,
205205
-- | control the schedule followed, and initial value
206206
control :: !ScheduleControl,

0 commit comments

Comments
 (0)