@@ -33,7 +33,7 @@ readRef = liftEffect <<< Ref.read
33
33
writeRef ∷ ∀ m a . MonadEffect m ⇒ Ref a → a → m Unit
34
34
writeRef r = liftEffect <<< flip Ref .write r
35
35
36
- modifyRef ∷ ∀ m a . MonadEffect m ⇒ Ref a → (a → a ) → m Unit
36
+ modifyRef ∷ ∀ m a . MonadEffect m ⇒ Ref a → (a → a ) → m a
37
37
modifyRef r = liftEffect <<< flip Ref .modify r
38
38
39
39
assertEff ∷ String → Either Error Boolean → Effect Unit
@@ -102,19 +102,19 @@ test_fork = assert "fork" do
102
102
fiber ← forkAff do
103
103
delay (Milliseconds 10.0 )
104
104
modifyRef ref (_ <> " child" )
105
- modifyRef ref (_ <> " go" )
105
+ _ ← modifyRef ref (_ <> " go" )
106
106
delay (Milliseconds 20.0 )
107
- modifyRef ref (_ <> " parent" )
107
+ _ ← modifyRef ref (_ <> " parent" )
108
108
eq " gochildparent" <$> readRef ref
109
109
110
110
test_join ∷ Aff Unit
111
111
test_join = assert " join" do
112
112
ref ← newRef " "
113
113
fiber ← forkAff do
114
114
delay (Milliseconds 10.0 )
115
- modifyRef ref (_ <> " child" )
115
+ _ ← modifyRef ref (_ <> " child" )
116
116
readRef ref
117
- modifyRef ref (_ <> " parent" )
117
+ _ ← modifyRef ref (_ <> " parent" )
118
118
eq " parentchild" <$> joinFiber fiber
119
119
120
120
test_join_throw ∷ Aff Unit
@@ -134,11 +134,11 @@ test_multi_join = assert "join/multi" do
134
134
ref ← newRef 1
135
135
f1 ← forkAff do
136
136
delay (Milliseconds 10.0 )
137
- modifyRef ref (_ + 1 )
137
+ _ ← modifyRef ref (_ + 1 )
138
138
pure 10
139
139
f2 ← forkAff do
140
140
delay (Milliseconds 20.0 )
141
- modifyRef ref (_ + 1 )
141
+ _ ← modifyRef ref (_ + 1 )
142
142
pure 20
143
143
n1 ← traverse joinFiber
144
144
[ f1
@@ -155,9 +155,9 @@ test_suspend = assert "suspend" do
155
155
fiber ← suspendAff do
156
156
delay (Milliseconds 10.0 )
157
157
modifyRef ref (_ <> " child" )
158
- modifyRef ref (_ <> " go" )
158
+ _ ← modifyRef ref (_ <> " go" )
159
159
delay (Milliseconds 20.0 )
160
- modifyRef ref (_ <> " parent" )
160
+ _ ← modifyRef ref (_ <> " parent" )
161
161
_ ← joinFiber fiber
162
162
eq " goparentchild" <$> readRef ref
163
163
@@ -185,7 +185,7 @@ test_bracket = assert "bracket" do
185
185
let
186
186
action s = do
187
187
delay (Milliseconds 10.0 )
188
- modifyRef ref (_ <> [ s ])
188
+ _ ← modifyRef ref (_ <> [ s ])
189
189
pure s
190
190
fiber ← forkAff do
191
191
delay (Milliseconds 40.0 )
@@ -206,7 +206,7 @@ test_bracket_nested = assert "bracket/nested" do
206
206
let
207
207
action s = do
208
208
delay (Milliseconds 10.0 )
209
- modifyRef ref (_ <> [ s ])
209
+ _ ← modifyRef ref (_ <> [ s ])
210
210
pure s
211
211
bracketAction s =
212
212
bracket
@@ -235,7 +235,7 @@ test_general_bracket = assert "bracket/general" do
235
235
let
236
236
action s = do
237
237
delay (Milliseconds 10.0 )
238
- modifyRef ref (_ <> s)
238
+ _ ← modifyRef ref (_ <> s)
239
239
pure s
240
240
bracketAction s =
241
241
generalBracket (action s)
@@ -265,13 +265,13 @@ test_supervise = assert "supervise" do
265
265
_ ← forkAff do
266
266
bracket
267
267
(modifyRef ref (_ <> " acquire" ))
268
- (\_ → modifyRef ref (_ <> " release" ))
268
+ (\_ → void $ modifyRef ref (_ <> " release" ))
269
269
(\_ → delay (Milliseconds 10.0 ))
270
270
_ ← forkAff do
271
271
delay (Milliseconds 11.0 )
272
- modifyRef ref (_ <> " delay" )
272
+ void $ modifyRef ref (_ <> " delay" )
273
273
delay (Milliseconds 5.0 )
274
- modifyRef ref (_ <> " done" )
274
+ _ ← modifyRef ref (_ <> " done" )
275
275
pure " done"
276
276
delay (Milliseconds 20.0 )
277
277
r2 ← readRef ref
@@ -303,7 +303,7 @@ test_kill_bracket = assert "kill/bracket" do
303
303
let
304
304
action n = do
305
305
delay (Milliseconds 10.0 )
306
- modifyRef ref (_ <> n)
306
+ void $ modifyRef ref (_ <> n)
307
307
fiber ←
308
308
forkAff $ bracket
309
309
(action " a" )
@@ -320,7 +320,7 @@ test_kill_bracket_nested = assert "kill/bracket/nested" do
320
320
let
321
321
action s = do
322
322
delay (Milliseconds 10.0 )
323
- modifyRef ref (_ <> [ s ])
323
+ _ ← modifyRef ref (_ <> [ s ])
324
324
pure s
325
325
bracketAction s =
326
326
bracket
@@ -350,13 +350,13 @@ test_kill_supervise = assert "kill/supervise" do
350
350
let
351
351
action s = generalBracket
352
352
(modifyRef ref (_ <> " acquire" <> s))
353
- { failed: \_ _ → modifyRef ref (_ <> " throw" <> s)
354
- , killed: \_ _ → modifyRef ref (_ <> " kill" <> s)
355
- , completed: \_ _ → modifyRef ref (_ <> " complete" <> s)
353
+ { failed: \_ _ → void $ modifyRef ref (_ <> " throw" <> s)
354
+ , killed: \_ _ → void $ modifyRef ref (_ <> " kill" <> s)
355
+ , completed: \_ _ → void $ modifyRef ref (_ <> " complete" <> s)
356
356
}
357
357
(\_ -> do
358
358
delay (Milliseconds 10.0 )
359
- modifyRef ref (_ <> " child" <> s))
359
+ void $ modifyRef ref (_ <> " child" <> s))
360
360
fiber ← forkAff $ supervise do
361
361
_ ← forkAff $ action " foo"
362
362
_ ← forkAff $ action " bar"
@@ -398,7 +398,7 @@ test_parallel = assert "parallel" do
398
398
let
399
399
action s = do
400
400
delay (Milliseconds 10.0 )
401
- modifyRef ref (_ <> s)
401
+ _ ← modifyRef ref (_ <> s)
402
402
pure s
403
403
f1 ← forkAff $ sequential $
404
404
{ a: _, b: _ }
@@ -415,7 +415,7 @@ test_parallel_throw = assert "parallel/throw" $ withTimeout (Milliseconds 100.0)
415
415
let
416
416
action n s = do
417
417
delay (Milliseconds n)
418
- modifyRef ref (_ <> s)
418
+ _ ← modifyRef ref (_ <> s)
419
419
pure s
420
420
r1 ← try $ sequential $
421
421
{ a: _, b: _ }
@@ -431,10 +431,10 @@ test_kill_parallel = assert "kill/parallel" do
431
431
action s = do
432
432
bracket
433
433
(pure unit)
434
- (\_ → modifyRef ref (_ <> " killed" <> s))
434
+ (\_ → void $ modifyRef ref (_ <> " killed" <> s))
435
435
(\_ → do
436
436
delay (Milliseconds 10.0 )
437
- modifyRef ref (_ <> s))
437
+ void $ modifyRef ref (_ <> s))
438
438
f1 ← forkAff $ sequential $
439
439
parallel (action " foo" ) *> parallel (action " bar" )
440
440
f2 ← forkAff do
@@ -451,7 +451,7 @@ test_parallel_alt = assert "parallel/alt" do
451
451
let
452
452
action n s = do
453
453
delay (Milliseconds n)
454
- modifyRef ref (_ <> s)
454
+ _ ← modifyRef ref (_ <> s)
455
455
pure s
456
456
f1 ← forkAff $ sequential $
457
457
parallel (action 10.0 " foo" ) <|> parallel (action 5.0 " bar" )
@@ -475,7 +475,7 @@ test_parallel_alt_sync = assert "parallel/alt/sync" do
475
475
action s = do
476
476
bracket
477
477
(pure unit)
478
- (\_ → modifyRef ref (_ <> " killed" <> s))
478
+ (\_ → void $ modifyRef ref (_ <> " killed" <> s))
479
479
(\_ → modifyRef ref (_ <> s) $> s)
480
480
r1 ← sequential $
481
481
parallel (action " foo" )
@@ -490,7 +490,7 @@ test_parallel_mixed = assert "parallel/mixed" do
490
490
let
491
491
action n s = parallel do
492
492
delay (Milliseconds n)
493
- modifyRef ref (_ <> s)
493
+ _ ← modifyRef ref (_ <> s)
494
494
pure s
495
495
{ r1, r2, r3 } ← sequential $
496
496
{ r1: _, r2: _, r3: _ }
@@ -512,10 +512,10 @@ test_kill_parallel_alt = assert "kill/parallel/alt" do
512
512
action n s = do
513
513
bracket
514
514
(pure unit)
515
- (\_ → modifyRef ref (_ <> " killed" <> s))
515
+ (\_ → void $ modifyRef ref (_ <> " killed" <> s))
516
516
(\_ → do
517
517
delay (Milliseconds n)
518
- modifyRef ref (_ <> s))
518
+ void $ modifyRef ref (_ <> s))
519
519
f1 ← forkAff $ sequential $
520
520
parallel (action 10.0 " foo" ) <|> parallel (action 20.0 " bar" )
521
521
f2 ← forkAff do
@@ -535,7 +535,7 @@ test_kill_parallel_alt_finalizer = assert "kill/parallel/alt/finalizer" do
535
535
(pure unit)
536
536
(\_ → do
537
537
delay (Milliseconds 10.0 )
538
- modifyRef ref (_ <> " killed" ))
538
+ void $ modifyRef ref (_ <> " killed" ))
539
539
(\_ → delay (Milliseconds 20.0 ))
540
540
f2 ← forkAff do
541
541
delay (Milliseconds 15.0 )
@@ -550,7 +550,7 @@ test_fiber_map = assert "fiber/map" do
550
550
ref ← newRef 0
551
551
let
552
552
mapFn a = unsafePerformEffect do
553
- Ref .modify (_ + 1 ) ref
553
+ _ ← Ref .modify (_ + 1 ) ref
554
554
pure (a + 1 )
555
555
f1 ← forkAff do
556
556
delay (Milliseconds 10.0 )
@@ -567,7 +567,7 @@ test_fiber_apply = assert "fiber/apply" do
567
567
ref ← newRef 0
568
568
let
569
569
applyFn a b = unsafePerformEffect do
570
- Ref .modify (_ + 1 ) ref
570
+ _ ← Ref .modify (_ + 1 ) ref
571
571
pure (a + b)
572
572
f1 ← forkAff do
573
573
delay (Milliseconds 10.0 )
@@ -592,7 +592,7 @@ test_efffn = assert "efffn" do
592
592
runAff_ (either (AC .runEffectFn1 cke) (AC .runEffectFn1 ckc)) (killFiber e fiber)
593
593
action = do
594
594
effectDelay (Milliseconds 10.0 )
595
- modifyRef ref (_ <> " done" )
595
+ void $ modifyRef ref (_ <> " done" )
596
596
f1 ← forkAff action
597
597
f2 ← forkAff action
598
598
killFiber (error " Nope." ) f2
0 commit comments