@@ -4,10 +4,10 @@ import Prelude
4
4
5
5
import Control.Alt ((<|>))
6
6
import Control.Apply ((*>))
7
+ import Control.Parallel.Class (parallel , runParallel )
7
8
import Control.Monad.Aff (Aff , runAff , makeAff , later , later' , forkAff , forkAll , Canceler (..), cancel , attempt , finally , apathize )
8
9
import Control.Monad.Aff.AVar (AVAR , makeVar , makeVar' , putVar , modifyVar , takeVar , killVar )
9
10
import Control.Monad.Aff.Console (log )
10
- import Control.Monad.Aff.Par (Par (..), runPar )
11
11
import Control.Monad.Cont.Class (callCC )
12
12
import Control.Monad.Eff (Eff )
13
13
import Control.Monad.Eff.Console (CONSOLE )
@@ -40,8 +40,8 @@ test_makeAff = unsafePartial do
40
40
asyncF <- attempt $ makeAff \reject resolve -> reject (error " ok" )
41
41
log $ " makeAff asynchronous failure is " <> message (fromLeft asyncF)
42
42
43
- asyncF <- attempt $ makeAff \reject resolve -> synchronousUnexpectedThrowError
44
- log $ " makeAff synchronous failure is " <> message (fromLeft asyncF)
43
+ asyncF' <- attempt $ makeAff \reject resolve -> synchronousUnexpectedThrowError
44
+ log $ " makeAff synchronous failure is " <> message (fromLeft asyncF' )
45
45
46
46
log " Success: makeAff is ok"
47
47
@@ -99,25 +99,25 @@ test_finally = do
99
99
100
100
test_parRace :: TestAVar Unit
101
101
test_parRace = do
102
- s <- runPar ( Par (later' 100 $ pure " Success: Early bird got the worm" ) <|>
103
- Par (later' 200 $ pure " Failure: Late bird got the worm" ))
102
+ s <- runParallel (parallel (later' 100 $ pure " Success: Early bird got the worm" ) <|>
103
+ parallel (later' 200 $ pure " Failure: Late bird got the worm" ))
104
104
log s
105
105
106
106
test_parError :: TestAVar Unit
107
107
test_parError = do
108
- e <- attempt $ runPar ( Par (throwError (error (" Oh noes!" ))) *> pure unit)
108
+ e <- attempt $ runParallel (parallel (throwError (error (" Oh noes!" ))) *> pure unit)
109
109
either (const $ log " Success: Exception propagated" ) (const $ log " Failure: Exception missing" ) e
110
110
111
111
test_parRaceKill1 :: TestAVar Unit
112
112
test_parRaceKill1 = do
113
- s <- runPar ( Par (later' 100 $ throwError (error (" Oh noes!" ))) <|>
114
- Par (later' 200 $ pure " Success: Early error was ignored in favor of late success" ))
113
+ s <- runParallel (parallel (later' 100 $ throwError (error (" Oh noes!" ))) <|>
114
+ parallel (later' 200 $ pure " Success: Early error was ignored in favor of late success" ))
115
115
log s
116
116
117
117
test_parRaceKill2 :: TestAVar Unit
118
118
test_parRaceKill2 = do
119
- e <- attempt $ runPar ( Par (later' 100 $ throwError (error (" Oh noes!" ))) <|>
120
- Par (later' 200 $ throwError (error (" Oh noes!" ))))
119
+ e <- attempt $ runParallel (parallel (later' 100 $ throwError (error (" Oh noes!" ))) <|>
120
+ parallel (later' 200 $ throwError (error (" Oh noes!" ))))
121
121
either (const $ log " Success: Killing both kills it dead" ) (const $ log " Failure: It's alive!!!" ) e
122
122
123
123
test_semigroupCanceler :: Test Unit
@@ -137,13 +137,13 @@ test_cancelLater = do
137
137
v <- cancel c (error " Cause" )
138
138
log (if v then " Success: Canceled later" else " Failure: Did not cancel later" )
139
139
140
- test_cancelPar :: TestAVar Unit
141
- test_cancelPar = do
142
- c <- forkAff <<< runPar $ Par (later' 100 $ log " Failure: #1 should not get through" ) <|>
143
- Par (later' 100 $ log " Failure: #2 should not get through" )
140
+ test_cancelParallel :: TestAVar Unit
141
+ test_cancelParallel = do
142
+ c <- forkAff <<< runParallel $ parallel (later' 100 $ log " Failure: #1 should not get through" ) <|>
143
+ parallel (later' 100 $ log " Failure: #2 should not get through" )
144
144
v <- c `cancel` (error " Must cancel" )
145
- log (if v then " Success: Canceling composite of two Par succeeded"
146
- else " Failure: Canceling composite of two Par failed" )
145
+ log (if v then " Success: Canceling composite of two Parallel succeeded"
146
+ else " Failure: Canceling composite of two Parallel failed" )
147
147
148
148
test_syncTailRecM :: TestAVar Unit
149
149
test_syncTailRecM = do
@@ -224,20 +224,20 @@ main = runAff throwException (const (pure unit)) $ do
224
224
log " Testing finally"
225
225
test_finally
226
226
227
- log " Test Par (*>)"
227
+ log " Test Parallel (*>)"
228
228
test_parError
229
229
230
- log " Testing Par (<|>)"
230
+ log " Testing Parallel (<|>)"
231
231
test_parRace
232
232
233
- log " Testing Par (<|>) - kill one"
233
+ log " Testing Parallel (<|>) - kill one"
234
234
test_parRaceKill1
235
235
236
- log " Testing Par (<|>) - kill two"
236
+ log " Testing Parallel (<|>) - kill two"
237
237
test_parRaceKill2
238
238
239
- log " Testing cancel of Par (<|>)"
240
- test_cancelPar
239
+ log " Testing cancel of Parallel (<|>)"
240
+ test_cancelParallel
241
241
242
242
log " Testing synchronous tailRecM"
243
243
test_syncTailRecM
0 commit comments