Skip to content

Commit 9e96664

Browse files
authored
Merge pull request #110 from input-output-hk/coot/time
NFData & NoThunk instances for Time
2 parents 8293db5 + f124ae8 commit 9e96664

File tree

8 files changed

+70
-2
lines changed

8 files changed

+70
-2
lines changed

.github/workflows/haskell.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,22 @@ jobs:
188188
run: |
189189
./scripts/check-stylish.sh
190190
git diff --exit-code
191+
192+
check-changelogs:
193+
name: Check changelogs
194+
runs-on: ubuntu-latest
195+
defaults:
196+
run:
197+
shell: bash
198+
199+
steps:
200+
- name: Install dependencies
201+
run: sudo apt install -y fd-find
202+
203+
- uses: actions/checkout@v3
204+
205+
- name: git fetch
206+
run: git fetch origin main:main
207+
208+
- name: Check changelogs
209+
run: ./scripts/check-changelogs.sh

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])

scripts/check-changelogs.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
FD="$(which fdfind 2>/dev/null || which fd 2>/dev/null)"
4+
5+
set -eo pipefail
6+
7+
function check_project () {
8+
project=$1
9+
n=$()
10+
if [[ -n $(git diff --name-only origin/main..HEAD -- $project) ]];then
11+
if [[ -z $(git diff --name-only origin/main..HEAD -- $project/CHANGELOG.md) ]]; then
12+
echo "$project was modified but its CHANGELOG was not updated"
13+
exit 1
14+
fi
15+
fi
16+
}
17+
18+
for cbl in $($FD -e 'cabal'); do
19+
check_project $(dirname $cbl)
20+
done
21+

si-timers/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## next
4+
5+
## Non breaking changes
6+
7+
- Added NFData & NoThunks instances for `Time`
8+
39
## 1.1.0.0
410

511
### Non breaking changes

si-timers/si-timers.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ library
5353
ScopedTypeVariables,
5454
TypeFamilies
5555
build-depends: base >=4.9 && <4.19,
56+
deepseq,
5657
mtl,
58+
nothunks,
5759
stm,
5860
time >=1.9.1 && <1.13,
5961

si-timers/src/Control/Monad/Class/MonadTime/SI.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{-# LANGUAGE DefaultSignatures #-}
2+
{-# LANGUAGE DeriveAnyClass #-}
23
{-# LANGUAGE DeriveGeneric #-}
4+
{-# LANGUAGE DerivingStrategies #-}
5+
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
36
{-# LANGUAGE NumericUnderscores #-}
47

58
module Control.Monad.Class.MonadTime.SI
@@ -18,12 +21,15 @@ module Control.Monad.Class.MonadTime.SI
1821
) where
1922

2023
import Control.Monad.Reader
24+
import Control.DeepSeq (NFData (..))
2125

2226
import Control.Monad.Class.MonadTime ( MonadMonotonicTimeNSec,
2327
MonadTime (..), NominalDiffTime, UTCTime, diffUTCTime,
2428
addUTCTime)
2529
import qualified Control.Monad.Class.MonadTime as MonadTime
2630

31+
import NoThunks.Class (NoThunks (..))
32+
2733
import Data.Word (Word64)
2834
import Data.Time.Clock (DiffTime)
2935
import qualified Data.Time.Clock as Time
@@ -37,7 +43,9 @@ import GHC.Generics (Generic (..))
3743
-- program runs. It is represented as the 'DiffTime' from this arbitrary epoch.
3844
--
3945
newtype Time = Time DiffTime
40-
deriving (Eq, Ord, Show, Generic)
46+
deriving stock (Eq, Ord, Show, Generic)
47+
deriving newtype NFData
48+
deriving anyclass NoThunks
4149

4250
-- | The time duration between two points in time (positive or negative).
4351
diffTime :: Time -> Time -> DiffTime

0 commit comments

Comments
 (0)