@@ -10,7 +10,7 @@ import Prelude
10
10
11
11
import Control.Coroutine (Producer , producer )
12
12
import Control.Monad.Aff (Aff , runAff , forkAff )
13
- import Control.Monad.Aff.AVar (AVAR , makeVar , takeVar , putVar )
13
+ import Control.Monad.Aff.AVar (AVAR , makeEmptyVar , takeVar , putVar )
14
14
import Control.Monad.Aff.Class (class MonadAff , liftAff )
15
15
import Control.Monad.Eff (Eff )
16
16
import Control.Monad.Eff.Class (liftEff )
@@ -39,7 +39,7 @@ produce
39
39
. ((Either a r -> Eff (avar :: AVAR | eff ) Unit ) -> Eff (avar :: AVAR | eff ) Unit )
40
40
-> Producer a (Aff (avar :: AVAR | eff )) r
41
41
produce recv = produceAff \send ->
42
- liftEff (recv (void <<< runAff (const (pure unit)) pure <<< send))
42
+ liftEff (recv (void <<< runAff (const (pure unit)) <<< send))
43
43
44
44
-- | A version of `produce` that creates a `Producer` with an underlying
45
45
-- | `MonadAff`, rather than `Aff` specifically.
@@ -57,14 +57,16 @@ produce' = hoistFreeT liftAff <<< produce
57
57
-- |
58
58
-- | ```purescript
59
59
-- | produceAff \emit -> do
60
- -- | later' 1000 $ emit $ Left "progress"
61
- -- | later' 1000 $ emit $ Right "finished"
60
+ -- | delay $ Milliseconds 1000
61
+ -- | emit $ Left "progress"
62
+ -- | delay $ Milliseconds 1000
63
+ -- | emit $ Right "finished"
62
64
-- | ```
63
65
produceAff
64
66
:: forall a r eff
65
67
. ((Either a r -> Aff (avar :: AVAR | eff ) Unit ) -> Aff (avar :: AVAR | eff ) Unit )
66
68
-> Producer a (Aff (avar :: AVAR | eff )) r
67
69
produceAff recv = do
68
- v <- lift makeVar
69
- _ <- lift (forkAff (recv (putVar v)))
70
+ v <- lift makeEmptyVar
71
+ _ <- lift (forkAff (recv (flip putVar v)))
70
72
producer (takeVar v)
0 commit comments