@@ -4,10 +4,10 @@ import Prelude
44
55import Control.Alt ((<|>))
66import Control.Apply ((*>))
7+ import Control.Parallel.Class (parallel , runParallel )
78import Control.Monad.Aff (Aff , runAff , makeAff , later , later' , forkAff , forkAll , Canceler (..), cancel , attempt , finally , apathize )
89import Control.Monad.Aff.AVar (AVAR , makeVar , makeVar' , putVar , modifyVar , takeVar , killVar )
910import Control.Monad.Aff.Console (log )
10- import Control.Monad.Aff.Par (Par (..), runPar )
1111import Control.Monad.Cont.Class (callCC )
1212import Control.Monad.Eff (Eff )
1313import Control.Monad.Eff.Console (CONSOLE )
@@ -40,8 +40,8 @@ test_makeAff = unsafePartial do
4040 asyncF <- attempt $ makeAff \reject resolve -> reject (error " ok" )
4141 log $ " makeAff asynchronous failure is " <> message (fromLeft asyncF)
4242
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' )
4545
4646 log " Success: makeAff is ok"
4747
@@ -99,25 +99,25 @@ test_finally = do
9999
100100test_parRace :: TestAVar Unit
101101test_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" ))
104104 log s
105105
106106test_parError :: TestAVar Unit
107107test_parError = do
108- e <- attempt $ runPar ( Par (throwError (error (" Oh noes!" ))) *> pure unit)
108+ e <- attempt $ runParallel (parallel (throwError (error (" Oh noes!" ))) *> pure unit)
109109 either (const $ log " Success: Exception propagated" ) (const $ log " Failure: Exception missing" ) e
110110
111111test_parRaceKill1 :: TestAVar Unit
112112test_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" ))
115115 log s
116116
117117test_parRaceKill2 :: TestAVar Unit
118118test_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!" ))))
121121 either (const $ log " Success: Killing both kills it dead" ) (const $ log " Failure: It's alive!!!" ) e
122122
123123test_semigroupCanceler :: Test Unit
@@ -137,13 +137,13 @@ test_cancelLater = do
137137 v <- cancel c (error " Cause" )
138138 log (if v then " Success: Canceled later" else " Failure: Did not cancel later" )
139139
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" )
144144 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" )
147147
148148test_syncTailRecM :: TestAVar Unit
149149test_syncTailRecM = do
@@ -224,20 +224,20 @@ main = runAff throwException (const (pure unit)) $ do
224224 log " Testing finally"
225225 test_finally
226226
227- log " Test Par (*>)"
227+ log " Test Parallel (*>)"
228228 test_parError
229229
230- log " Testing Par (<|>)"
230+ log " Testing Parallel (<|>)"
231231 test_parRace
232232
233- log " Testing Par (<|>) - kill one"
233+ log " Testing Parallel (<|>) - kill one"
234234 test_parRaceKill1
235235
236- log " Testing Par (<|>) - kill two"
236+ log " Testing Parallel (<|>) - kill two"
237237 test_parRaceKill2
238238
239- log " Testing cancel of Par (<|>)"
240- test_cancelPar
239+ log " Testing cancel of Parallel (<|>)"
240+ test_cancelParallel
241241
242242 log " Testing synchronous tailRecM"
243243 test_syncTailRecM
0 commit comments