Skip to content

Commit 9952bfb

Browse files
committed
io-sim: NFData & NoThunks instances for ThreadId
1 parent 18aa515 commit 9952bfb

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

io-sim/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
### Non breaking changes
1515

1616
* Provide `MonadInspectMVar` instance for `IOSim`.
17+
- Added NFData & NoThunks instances for `ThreadId`
1718

1819
## 1.1.0.0
1920

io-sim/io-sim.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ library
7878
io-classes ^>=1.1,
7979
exceptions >=0.10,
8080
containers,
81+
deepseq,
8182
nothunks,
8283
parallel,
8384
psqueues >=0.2 && <0.3,

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
{-# LANGUAGE DeriveAnyClass #-}
2+
{-# LANGUAGE DeriveGeneric #-}
3+
{-# LANGUAGE DerivingStrategies #-}
14
{-# LANGUAGE GADTs #-}
25
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
36
{-# LANGUAGE ScopedTypeVariables #-}
@@ -6,12 +9,16 @@
69
--
710
module Control.Monad.IOSim.CommonTypes where
811

12+
import Control.DeepSeq (NFData (..))
913
import Control.Monad.Class.MonadSTM (TraceValue)
1014
import Control.Monad.ST.Lazy
1115

16+
import NoThunks.Class
17+
1218
import Data.Map (Map)
1319
import Data.STRef.Lazy
1420
import Data.Set (Set)
21+
import GHC.Generics
1522

1623

1724
-- | A thread id.
@@ -23,7 +30,10 @@ import Data.Set (Set)
2330
--
2431
data ThreadId = RacyThreadId [Int]
2532
| ThreadId [Int] -- non racy threads have higher priority
26-
deriving (Eq, Ord, Show)
33+
deriving stock (Eq, Ord, Show, Generic)
34+
deriving anyclass NFData
35+
deriving anyclass NoThunks
36+
2737

2838
childThreadId :: ThreadId -> Int -> ThreadId
2939
childThreadId (RacyThreadId is) i = RacyThreadId (is ++ [i])

0 commit comments

Comments
 (0)