Skip to content

Commit 90b4802

Browse files
committed
fixup! fixup! fixup! io-sim: Add support for unique symbol generation
1 parent e87218c commit 90b4802

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,13 @@ ppLabelled pp Labelled { l_labelled = a, l_label = Just lbl } = concat ["Labelle
207207
-- | Abstract unique symbols à la "Data.Unique".
208208
newtype Unique s = MkUnique{ unMkUnique :: Integer }
209209
deriving stock (Eq, Ord)
210-
deriving newtype (Hashable, NFData)
210+
deriving newtype NFData
211211
type role Unique nominal
212212

213+
instance Hashable (Unique s) where
214+
hash = fromInteger . unMkUnique
215+
hashWithSalt = defaultHashWithSalt
216+
213217
--
214218
-- Utils
215219
--

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ 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))
108109
import Data.List.Trace qualified as Trace
109110
import Data.Map.Strict (Map)
110111
import Data.Maybe (fromMaybe)
@@ -632,7 +633,7 @@ instance MonadLabelledMVar (IOSim s) where
632633
instance MonadUnique (IOSim s) where
633634
type Unique (IOSim s) = Sim.Unique s
634635
newUnique = IOSim (oneShot NewUnique)
635-
hashUnique = fromInteger . unMkUnique
636+
hashUnique = hash
636637

637638
data Async s a = Async !IOSimThreadId (STM s (Either SomeException a))
638639

0 commit comments

Comments
 (0)