Module
Run.Streaming
- Package
- purescript-run
- Repository
- natefaubion/purescript-run
This module defines primitive combinators for both push and pull streams.
map ∷ ∀ x y r a. (x → y) → Transformer r x y a
map f = forever do
x ← await
yield (f x)
take ∷ ∀ x r. Int → Transformer r x x Unit
take n
| n <= 0 = pure unit
| otherwise = do
await >>= yield
take (n - 1)
naturals ∷ ∀ r a. Producer r Int a
naturals = go 1
where
go n = do
yield n
go (n + 1)
toConsole ∷ ∀ eff r a. Consumer (base ∷ BaseEff (console ∷ CONSOLE | eff) | r) String a
toConsole = forever (await >>= log >>> liftBase)
main ∷ Eff (console ∷ CONSOLE) Unit
main = runBase $
naturals
!> take 100
!> map show
!> toConsole