1{-# LANGUAGE UndecidableInstances #-}
3-- Module : Streamly.Internal.Data.Stream.Concurrent
4-- Copyright : (c) 2017 Composewell Technologies
5-- License : BSD-3-Clause
6-- Maintainer : streamly@composewell.com
7-- Stability : experimental
10-- To run examples in this module:
12-- >>> import qualified Streamly.Internal.Data.Stream as Stream
13-- >>> import qualified Streamly.Data.Fold as Fold
15module Streamly.Internal.Data.Stream.Zip.Concurrent
21import Streamly.Internal.Data.Stream.StreamD (Stream)
22import Streamly.Internal.Data.Stream.Concurrent (MonadAsync, parZipWith)
24import qualified Streamly.Internal.Data.Stream.StreamD as Stream (repeat)
25import Prelude hiding (map, repeat, zipWith)
28-- >>> import qualified Streamly.Internal.Data.Stream as Stream
29-- >>> import qualified Streamly.Data.Fold as Fold
32newtype ZipConcurrent m a = ZipConcurrent {getZipConcurrent :: Stream m a}
35-- | An IO stream whose applicative instance zips streams concurrently. Note
36-- that it uses the default concurrency options.
38-- >>> s = ZipConcurrent $ Stream.fromList [1, 2, 3]
39-- >>> x = (,,) <$> s <*> s <*> s
40-- >>> Stream.fold Fold.toList (getZipConcurrent x)
41-- [(1,1,1),(2,2,2),(3,3,3)]
45instance MonadAsync m => Applicative (ZipConcurrent m) where
46 pure = ZipConcurrent . Stream.repeat
49 ZipConcurrent m1 <*> ZipConcurrent m2 =
50 ZipConcurrent $ parZipWith id id m1 m2
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list