Skip to content

Commit

Permalink
Pull example
Browse files Browse the repository at this point in the history
  • Loading branch information
natefaubion committed Apr 28, 2017
1 parent d3e9c2c commit ab72820
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Run/Streaming.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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 !<
19 changes: 13 additions & 6 deletions test/Streaming.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit ab72820

Please sign in to comment.