Skip to content

Commit 262268a

Browse files
committed
io-sim-por: refactor racingEffects
1 parent 6e25138 commit 262268a

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,13 +1337,20 @@ racingEffects :: Effect -> Effect -> Bool
13371337
racingEffects e e' =
13381338
(effectLiftST e && racesWithLiftST e')
13391339
|| (effectLiftST e' && racesWithLiftST e )
1340-
|| (not $ null $ effectThrows e `List.intersect` effectThrows e')
1341-
|| (not $ effectReads e `Set.disjoint` effectWrites e'
1342-
&& effectWrites e `Set.disjoint` effectReads e'
1343-
&& effectWrites e `Set.disjoint` effectWrites e')
1344-
where racesWithLiftST eff =
1345-
effectLiftST eff
1346-
|| not (Set.null (effectReads eff) && Set.null (effectWrites eff))
1340+
|| effectThrows e `intersectsL` effectThrows e'
1341+
|| effectReads e `intersects` effectWrites e'
1342+
|| effectWrites e `intersects` effectReads e'
1343+
|| effectWrites e `intersects` effectWrites e'
1344+
where
1345+
intersects :: Ord a => Set a -> Set a -> Bool
1346+
intersects a b = not $ a `Set.disjoint` b
1347+
1348+
intersectsL :: Eq a => [a] -> [a] -> Bool
1349+
intersectsL a b = not $ null $ a `List.intersect` b
1350+
1351+
racesWithLiftST eff =
1352+
effectLiftST eff
1353+
|| not (Set.null (effectReads eff) && Set.null (effectWrites eff))
13471354

13481355
--
13491356
-- Steps

0 commit comments

Comments
 (0)