From ab728201905ef522d8a8ce93893a9a56524233d3 Mon Sep 17 00:00:00 2001 From: Nathan Faubion Date: Fri, 28 Apr 2017 15:16:10 -0500 Subject: [PATCH] Pull example --- src/Run/Streaming.purs | 2 +- test/Streaming.purs | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Run/Streaming.purs b/src/Run/Streaming.purs index a2ac33a..0f087c6 100644 --- a/src/Run/Streaming.purs +++ b/src/Run/Streaming.purs @@ -145,4 +145,4 @@ infixl 6 push as !> pull ∷ ∀ r a o. Consumer r o a → Producer r o a → Run r a pull ra rb = join $ fuse <$> runConsumer ra <*> runProducer rb -infixl 6 pull as !< +infixr 6 pull as !< diff --git a/test/Streaming.purs b/test/Streaming.purs index 713f559..afc5c8e 100644 --- a/test/Streaming.purs +++ b/test/Streaming.purs @@ -4,7 +4,7 @@ import Prelude hiding (map) import Control.Monad.Eff (Eff) import Control.Monad.Eff.Console (CONSOLE, log) import Run (Run, runBase, liftBase, BaseEff) -import Run.Streaming (Producer, Consumer, Transformer, (!>), yield, await) +import Run.Streaming (Producer, Consumer, Transformer, (!>), (!<), yield, await) forever ∷ ∀ r a b. Run r a → Run r b forever go = go >>= \_ → forever go @@ -30,8 +30,15 @@ toConsole ∷ ∀ eff r a. Consumer (base ∷ BaseEff (console ∷ CONSOLE | eff toConsole = forever (await >>= log >>> liftBase) main ∷ Eff (console ∷ CONSOLE) Unit -main = runBase $ - naturals - !> take 10 - !> map (show >>> append "Stream: ") - !> toConsole +main = do + runBase $ + naturals + !> take 10 + !> map (show >>> append "Push: ") + !> toConsole + + runBase $ + toConsole + !< map (append "Pull: " <<< show) + !< take 10 + !< naturals