on master help sign in
Rename to Streamly
a74a0c0Harendra Kumar
README.md+10−10
@@ -1,20 +1,20 @@
1−# Asyncly
1+# Streamly
2
2
3−[![Build Status](https://travis-ci.org/harendra-kumar/asyncly.svg?branch=master)](https://travis-ci.org/harendra-kumar/asyncly)
3+[![Build Status](https://travis-ci.org/harendra-kumar/streamly.svg?branch=master)](https://travis-ci.org/harendra-kumar/streamly)
4−[![Windows Build status](https://ci.appveyor.com/api/projects/status/h2bcgw7xa2jxe222?svg=true)](https://ci.appveyor.com/project/harendra-kumar/asyncly)
4+[![Windows Build status](https://ci.appveyor.com/api/projects/status/h2bcgw7xa2jxe222?svg=true)](https://ci.appveyor.com/project/harendra-kumar/streamly)
5−[![Coverage Status](https://coveralls.io/repos/harendra-kumar/asyncly/badge.svg?branch=master&service=github)](https://coveralls.io/github/harendra-kumar/asyncly?branch=master)
5+[![Coverage Status](https://coveralls.io/repos/harendra-kumar/streamly/badge.svg?branch=master&service=github)](https://coveralls.io/github/harendra-kumar/streamly?branch=master)
6
6
7−Asyncly is a general streaming and concurrent programming
7+Streamly is a general streaming and concurrent programming
8monad allowing you to write a wide variety of applications ranging from
8monad allowing you to write a wide variety of applications ranging from
9simple applications utilizing streaming IO to massively parallel concurrent
9simple applications utilizing streaming IO to massively parallel concurrent
10applications as well as reactive (FRP) applications with the same ease.
10applications as well as reactive (FRP) applications with the same ease.
11−Asyncly provides high level concurrency primitives and hides the low level
11+Streamly provides high level concurrency primitives and hides the low level
12concurrency details completely from the programmer. The programmer just
12concurrency details completely from the programmer. The programmer just
13expresses whether a task can run in parallel with another. Threads,
13expresses whether a task can run in parallel with another. Threads,
14synchronization and concurrency rate control are handled automatically. The
14synchronization and concurrency rate control are handled automatically. The
15library has been written keeping high performance applications in mind.
15library has been written keeping high performance applications in mind.
16
16
17−Asyncly subsumes all the use cases of list transformer (list-t) and logic
17+Streamly subsumes all the use cases of list transformer (list-t) and logic
18programming (logict) monads and adds concurrency on top. It is a streaming
18programming (logict) monads and adds concurrency on top. It is a streaming
19library and therefore can be used for most of the streaming use cases as well
19library and therefore can be used for most of the streaming use cases as well
20(i.e. where you would use conduit or pipes) with concurrency added. It is
20(i.e. where you would use conduit or pipes) with concurrency added. It is
@@ -29,16 +29,16 @@ directory tree:
29
29
30``` haskell
30``` haskell
31import Path.IO (listDir, getCurrentDir)
31import Path.IO (listDir, getCurrentDir)
32−import Asyncly
32+import Streamly
33
33
34−main = runAsyncly $ getCurrentDir >>= readdir
34+main = runStreaming $ serially $ getCurrentDir >>= readdir
35 where readdir d = do
35 where readdir d = do
36 (dirs, files) <- lift $ listDir d
36 (dirs, files) <- lift $ listDir d
37 liftIO $ mapM_ putStrLn $ map show files
37 liftIO $ mapM_ putStrLn $ map show files
38 foldMapWith (<|>) readdir dirs
38 foldMapWith (<|>) readdir dirs
39```
39```
40
40
41−See "Asyncly.Tutorial" and "Asyncly.Examples" for more details.
41+See "Streamly.Tutorial" and "Streamly.Examples" for more details.
42
42
43This library was originally inspired by the `transient`
43This library was originally inspired by the `transient`
44package authored by Alberto G. Corona.
44package authored by Alberto G. Corona.
benchmark/Main.hs+33−33
@@ -9,8 +9,8 @@ import Control.Monad (guard)
9import Criterion.Main (defaultMain, bgroup, bench, nfIO)
9import Criterion.Main (defaultMain, bgroup, bench, nfIO)
10import Data.Function ((&))
10import Data.Function ((&))
11
11
12−import qualified Asyncly as A
12+import qualified Streamly as A
13−import qualified Asyncly.Prelude as A
13+import qualified Streamly.Prelude as A
14
14
15#ifdef EXTRA_BENCHMARKS
15#ifdef EXTRA_BENCHMARKS
16import Control.Monad.IO.Class (MonadIO (liftIO))
16import Control.Monad.IO.Class (MonadIO (liftIO))
@@ -32,13 +32,13 @@ main :: IO ()
32main = do
32main = do
33 -- XXX due to a GHC bug passing bind as an argument causes perf
33 -- XXX due to a GHC bug passing bind as an argument causes perf
34 -- degradation, so we should keep that in account when comparing.
34 -- degradation, so we should keep that in account when comparing.
35− let as = asyncly_serial
35+ let as = streamly_serial
36− ai = asyncly_interleaved
36+ ai = streamly_interleaved
37− aa = asyncly_async
37+ aa = streamly_async
38− ap = asyncly_parallel
38+ ap = streamly_parallel
39 defaultMain [
39 defaultMain [
40− bgroup "asyncly"
40+ bgroup "streamly"
41− [ bench "function style all serial" $ nfIO asyncly_function_style
41+ [ bench "function style all serial" $ nfIO streamly_function_style
42
42
43 , bgroup "serial bind"
43 , bgroup "serial bind"
44 [ bench "serial" $ nfIO (as (A.<>))
44 [ bench "serial" $ nfIO (as (A.<>))
@@ -70,10 +70,10 @@ main = do
70
70
71 -- Benchmark smallest possible actions composed together
71 -- Benchmark smallest possible actions composed together
72 , bgroup "serial bind nil"
72 , bgroup "serial bind nil"
73− [ bench "serial" $ nfIO (asyncly_nil (A.<>))
73+ [ bench "serial" $ nfIO (streamly_nil (A.<>))
74− , bench "fair serial" $ nfIO (asyncly_nil (A.<=>))
74+ , bench "fair serial" $ nfIO (streamly_nil (A.<=>))
75− , bench "left parallel" $ nfIO (asyncly_nil (A.<|))
75+ , bench "left parallel" $ nfIO (streamly_nil (A.<|))
76− , bench "fair parallel" $ nfIO (asyncly_nil (A.<|>))
76+ , bench "fair parallel" $ nfIO (streamly_nil (A.<|>))
77 ]
77 ]
78 ]
78 ]
79#ifdef EXTRA_BENCHMARKS
79#ifdef EXTRA_BENCHMARKS
@@ -105,13 +105,13 @@ amap = Main.map
105afilter :: (Alternative (s IO), Monad (s IO)) => (Int -> Bool) -> Int -> s IO Int
105afilter :: (Alternative (s IO), Monad (s IO)) => (Int -> Bool) -> Int -> s IO Int
106afilter = Main.filter
106afilter = Main.filter
107
107
108−{-# INLINE asyncly_basic #-}
108+{-# INLINE streamly_basic #-}
109−asyncly_basic
109+streamly_basic
110 :: (Alternative (t IO), Monad (t IO), A.Streaming t)
110 :: (Alternative (t IO), Monad (t IO), A.Streaming t)
111 => (forall a. t IO a -> IO [a])
111 => (forall a. t IO a -> IO [a])
112 -> (t IO Int -> t IO Int -> t IO Int)
112 -> (t IO Int -> t IO Int -> t IO Int)
113 -> IO Int
113 -> IO Int
114−asyncly_basic tl g = do
114+streamly_basic tl g = do
115 xs <- tl $ do
115 xs <- tl $ do
116 A.drop 100 (A.forEachWith g [1..100000 :: Int] $ \x ->
116 A.drop 100 (A.forEachWith g [1..100000 :: Int] $ \x ->
117 afilter even x >>= amap (+1))
117 afilter even x >>= amap (+1))
@@ -120,9 +120,9 @@ asyncly_basic tl g = do
120 assert (Prelude.length xs == 49900) $
120 assert (Prelude.length xs == 49900) $
121 return (Prelude.length xs)
121 return (Prelude.length xs)
122
122
123−{-# INLINE asyncly_function_style #-}
123+{-# INLINE streamly_function_style #-}
124−asyncly_function_style :: IO Int
124+streamly_function_style :: IO Int
125−asyncly_function_style = do
125+streamly_function_style = do
126 xs <- A.toList $ A.serially $
126 xs <- A.toList $ A.serially $
127 A.each [1..100000 :: Int]
127 A.each [1..100000 :: Int]
128 & A.filter even
128 & A.filter even
@@ -133,34 +133,34 @@ asyncly_function_style = do
133 assert (Prelude.length xs == 49900) $
133 assert (Prelude.length xs == 49900) $
134 return (Prelude.length xs)
134 return (Prelude.length xs)
135
135
136−{-# INLINE asyncly_serial #-}
136+{-# INLINE streamly_serial #-}
137−asyncly_serial
137+streamly_serial
138 :: (A.StreamT IO Int -> A.StreamT IO Int -> A.StreamT IO Int)
138 :: (A.StreamT IO Int -> A.StreamT IO Int -> A.StreamT IO Int)
139 -> IO Int
139 -> IO Int
140−asyncly_serial = asyncly_basic (A.toList . A.serially)
140+streamly_serial = streamly_basic (A.toList . A.serially)
141
141
142−{-# INLINE asyncly_interleaved #-}
142+{-# INLINE streamly_interleaved #-}
143−asyncly_interleaved
143+streamly_interleaved
144 :: (A.InterleavedT IO Int -> A.InterleavedT IO Int -> A.InterleavedT IO Int)
144 :: (A.InterleavedT IO Int -> A.InterleavedT IO Int -> A.InterleavedT IO Int)
145 -> IO Int
145 -> IO Int
146−asyncly_interleaved = asyncly_basic (A.toList . A.interleaving)
146+streamly_interleaved = streamly_basic (A.toList . A.interleaving)
147
147
148−{-# INLINE asyncly_async #-}
148+{-# INLINE streamly_async #-}
149−asyncly_async
149+streamly_async
150 :: (A.AsyncT IO Int -> A.AsyncT IO Int -> A.AsyncT IO Int)
150 :: (A.AsyncT IO Int -> A.AsyncT IO Int -> A.AsyncT IO Int)
151 -> IO Int
151 -> IO Int
152−asyncly_async = asyncly_basic (A.toList . A.asyncly)
152+streamly_async = streamly_basic (A.toList . A.asyncly)
153
153
154−{-# INLINE asyncly_parallel #-}
154+{-# INLINE streamly_parallel #-}
155−asyncly_parallel
155+streamly_parallel
156 :: (A.ParallelT IO Int -> A.ParallelT IO Int -> A.ParallelT IO Int)
156 :: (A.ParallelT IO Int -> A.ParallelT IO Int -> A.ParallelT IO Int)
157 -> IO Int
157 -> IO Int
158−asyncly_parallel = asyncly_basic (A.toList . A.parallely)
158+streamly_parallel = streamly_basic (A.toList . A.parallely)
159
159
160−{-# INLINE asyncly_nil #-}
160+{-# INLINE streamly_nil #-}
161−asyncly_nil :: (A.StreamT IO Int -> A.StreamT IO Int -> A.StreamT IO Int)
161+streamly_nil :: (A.StreamT IO Int -> A.StreamT IO Int -> A.StreamT IO Int)
162 -> IO Int
162 -> IO Int
163−asyncly_nil f = do
163+streamly_nil f = do
164 xs <- (A.toList . A.serially) $ do
164 xs <- (A.toList . A.serially) $ do
165 (A.forEachWith f [1..100000:: Int] $
165 (A.forEachWith f [1..100000:: Int] $
166 \x -> return x >>= return . id)
166 \x -> return x >>= return . id)
examples/echo-loop.hs+1−1
@@ -1,5 +1,5 @@
1import Control.Monad.IO.Class (liftIO)
1import Control.Monad.IO.Class (liftIO)
2−import Asyncly
2+import Streamly
3
3
4input :: StreamT IO String
4input :: StreamT IO String
5input = do
5input = do
examples/loops.hs+1−1
@@ -1,4 +1,4 @@
1−import Asyncly
1+import Streamly
2import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
2import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
3
3
4main = do
4main = do
examples/map-reduce.hs+2−2
@@ -1,5 +1,5 @@
1−import Asyncly
1+import Streamly
2−import Asyncly.Prelude as A
2+import Streamly.Prelude as A
3
3
4main = do
4main = do
5 s <- A.sum $ serially $ forEachWith (<|) [1..100] $ \x -> return (x * x)
5 s <- A.sum $ serially $ forEachWith (<|) [1..100] $ \x -> return (x * x)
examples/nested-loops.hs+1−1
@@ -3,7 +3,7 @@ import Control.Concurrent (myThreadId)
3import Control.Monad.IO.Class (liftIO)
3import Control.Monad.IO.Class (liftIO)
4import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
4import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
5import System.Random (randomIO)
5import System.Random (randomIO)
6−import Asyncly
6+import Streamly
7
7
8main = runStreamT $ do
8main = runStreamT $ do
9 liftIO $ hSetBuffering stdout LineBuffering
9 liftIO $ hSetBuffering stdout LineBuffering
examples/parallel-loops.hs+1−1
@@ -3,7 +3,7 @@ import Control.Concurrent (myThreadId, threadDelay)
3import Control.Monad.IO.Class (liftIO)
3import Control.Monad.IO.Class (liftIO)
4import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
4import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
5import System.Random (randomIO)
5import System.Random (randomIO)
6−import Asyncly
6+import Streamly
7
7
8main = runStreamT $ do
8main = runStreamT $ do
9 liftIO $ hSetBuffering stdout LineBuffering
9 liftIO $ hSetBuffering stdout LineBuffering
src/Asyncly.hs → src/Streamly.hsrenamed+11−11
@@ -1,5 +1,5 @@
1-- |
1-- |
2−-- Module : Asyncly
2+-- Module : Streamly
3-- Copyright : (c) 2017 Harendra Kumar
3-- Copyright : (c) 2017 Harendra Kumar
4--
4--
5-- License : BSD3
5-- License : BSD3
@@ -37,21 +37,21 @@
37-- <https://hackage.haskell.org/package/reflex reflex>).
37-- <https://hackage.haskell.org/package/reflex reflex>).
38--
38--
39-- When it comes to streaming composition, if @conduit@ or @pipes@ are arrows
39-- When it comes to streaming composition, if @conduit@ or @pipes@ are arrows
40−-- then asyncly is monad. Streaming libraries like conduit or pipes provide
40+-- then streamly is monad. Streaming libraries like conduit or pipes provide
41−-- a categorical composition (sum) of streams whereas asyncly provides a more
41+-- a categorical composition (sum) of streams whereas streamly provides a more
42−-- general monadic composition (product) of streams, with concurrency. Asyncly
42+-- general monadic composition (product) of streams, with concurrency.
43−-- interworks with major streaming libraries providing a way to use both types
43+-- Streamly interworks with major streaming libraries providing a way to use
44−-- of compositions and using the right tool at the right place.
44+-- both types of compositions and using the right tool at the right place.
45−-- When it comes to concurrency, asyncly may be comared with
45+-- When it comes to concurrency, streamly may be comared with imperative style
46−-- imperative style concurrency frameworks like
46+-- concurrency frameworks like
47-- <https://en.wikipedia.org/wiki/OpenMP OpenMP> or
47-- <https://en.wikipedia.org/wiki/OpenMP OpenMP> or
48-- <https://en.wikipedia.org/wiki/Cilk Cilk>.
48-- <https://en.wikipedia.org/wiki/Cilk Cilk>.
49--
49--
50−-- For more details please see the 'Asyncly.Tutorial' and 'Asyncly.Examples'.
50+-- For more details please see the 'Streamly.Tutorial' and 'Streamly.Examples'.
51
51
52-- A simple inline example here illustrating applicative, monad and alternative
52-- A simple inline example here illustrating applicative, monad and alternative
53-- compositions.
53-- compositions.
54−module Asyncly
54+module Streamly
55 ( MonadAsync
55 ( MonadAsync
56 , Streaming
56 , Streaming
57
57
@@ -104,7 +104,7 @@ module Asyncly
104 )
104 )
105where
105where
106
106
107−import Asyncly.Streams
107+import Streamly.Streams
108import Data.Semigroup (Semigroup(..))
108import Data.Semigroup (Semigroup(..))
109import Control.Applicative (Alternative(..))
109import Control.Applicative (Alternative(..))
110import Control.Monad (MonadPlus(..))
110import Control.Monad (MonadPlus(..))
src/Asyncly/Core.hs → src/Streamly/Core.hsrenamed+2−2
@@ -6,7 +6,7 @@
6{-# LANGUAGE UndecidableInstances #-} -- XXX
6{-# LANGUAGE UndecidableInstances #-} -- XXX
7
7
8-- |
8-- |
9−-- Module : Asyncly.Core
9+-- Module : Streamly.Core
10-- Copyright : (c) 2017 Harendra Kumar
10-- Copyright : (c) 2017 Harendra Kumar
11--
11--
12-- License : BSD3
12-- License : BSD3
@@ -15,7 +15,7 @@
15-- Portability : GHC
15-- Portability : GHC
16--
16--
17--
17--
18−module Asyncly.Core
18+module Streamly.Core
19 (
19 (
20 MonadAsync
20 MonadAsync
21
21
src/Asyncly/Examples/AcidRainGame.hs → src/Streamly/Examples/AcidRainGame.hsrenamed+2−2
@@ -3,9 +3,9 @@
3-- This example is adapted from Gabriel Gonzalez's pipes-concurrency package.
3-- This example is adapted from Gabriel Gonzalez's pipes-concurrency package.
4-- https://hackage.haskell.org/package/pipes-concurrency-2.0.8/docs/Pipes-Concurrent-Tutorial.html
4-- https://hackage.haskell.org/package/pipes-concurrency-2.0.8/docs/Pipes-Concurrent-Tutorial.html
5
5
6−module Asyncly.Examples.AcidRainGame where
6+module Streamly.Examples.AcidRainGame where
7
7
8−import Asyncly
8+import Streamly
9import Control.Concurrent (threadDelay)
9import Control.Concurrent (threadDelay)
10import Control.Monad (when)
10import Control.Monad (when)
11import Control.Monad.State
11import Control.Monad.State
src/Asyncly/Examples/CirclingSquare.hs → src/Streamly/Examples/CirclingSquare.hsrenamed+4−4
@@ -1,16 +1,16 @@
1-- Adapted from the Yampa package.
1-- Adapted from the Yampa package.
2-- Displays a square moving in a circle. To move the position drag the mouse.
2-- Displays a square moving in a circle. To move the position drag the mouse.
3--
3--
4−-- Requires the SDL package, assuming asyncly has already been built, you can
4+-- Requires the SDL package, assuming streamly has already been built, you can
5-- compile it like this:
5-- compile it like this:
6-- stack ghc --package SDL circle-mouse.hs
6-- stack ghc --package SDL circle-mouse.hs
7
7
8−module Asyncly.Examples.CirclingSquare where
8+module Streamly.Examples.CirclingSquare where
9
9
10import Data.IORef
10import Data.IORef
11import Graphics.UI.SDL as SDL
11import Graphics.UI.SDL as SDL
12−import Asyncly
12+import Streamly
13−import Asyncly.Time
13+import Streamly.Time
14
14
15------------------------------------------------------------------------------
15------------------------------------------------------------------------------
16-- SDL Graphics Init
16-- SDL Graphics Init
src/Asyncly/Examples/ListDirRecursive.hs → src/Streamly/Examples/ListDirRecursive.hsrenamed+2−2
@@ -1,10 +1,10 @@
1{-# LANGUAGE FlexibleContexts #-}
1{-# LANGUAGE FlexibleContexts #-}
2
2
3−module Asyncly.Examples.ListDirRecursive where
3+module Streamly.Examples.ListDirRecursive where
4
4
5import Path.IO (listDir, getCurrentDir)
5import Path.IO (listDir, getCurrentDir)
6import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
6import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
7−import Asyncly
7+import Streamly
8
8
9listDirRecursive :: IO ()
9listDirRecursive :: IO ()
10listDirRecursive = do
10listDirRecursive = do
src/Asyncly/Examples/MergeSortedStreams.hs → src/Streamly/Examples/MergeSortedStreams.hsrenamed+3−3
@@ -1,12 +1,12 @@
1{-# LANGUAGE FlexibleContexts #-}
1{-# LANGUAGE FlexibleContexts #-}
2
2
3−module Asyncly.Examples.MergeSortedStreams where
3+module Streamly.Examples.MergeSortedStreams where
4
4
5import Data.Word
5import Data.Word
6import System.Random
6import System.Random
7import Data.List (sort)
7import Data.List (sort)
8−import Asyncly
8+import Streamly
9−import qualified Asyncly.Prelude as A
9+import qualified Streamly.Prelude as A
10
10
11getSorted :: MonadIO m => StreamT m Word16
11getSorted :: MonadIO m => StreamT m Word16
12getSorted = do
12getSorted = do
src/Asyncly/Examples/SearchEngineQuery.hs → src/Streamly/Examples/SearchEngineQuery.hsrenamed+2−2
@@ -1,6 +1,6 @@
1−module Asyncly.Examples.SearchEngineQuery where
1+module Streamly.Examples.SearchEngineQuery where
2
2
3−import Asyncly
3+import Streamly
4import Network.HTTP.Simple
4import Network.HTTP.Simple
5
5
6-- Runs three search engine queries in parallel.
6-- Runs three search engine queries in parallel.
src/Asyncly/Prelude.hs → src/Streamly/Prelude.hsrenamed+4−4
@@ -8,7 +8,7 @@
8{-# LANGUAGE UndecidableInstances #-} -- XXX
8{-# LANGUAGE UndecidableInstances #-} -- XXX
9
9
10-- |
10-- |
11−-- Module : Asyncly.Prelude
11+-- Module : Streamly.Prelude
12-- Copyright : (c) 2017 Harendra Kumar
12-- Copyright : (c) 2017 Harendra Kumar
13--
13--
14-- License : BSD3
14-- License : BSD3
@@ -17,7 +17,7 @@
17-- Portability : GHC
17-- Portability : GHC
18--
18--
19--
19--
20−module Asyncly.Prelude
20+module Streamly.Prelude
21 (
21 (
22 -- * Construction
22 -- * Construction
23 cons
23 cons
@@ -81,8 +81,8 @@ import Prelude hiding (filter, drop, dropWhile, take,
81import qualified Prelude as Prelude
81import qualified Prelude as Prelude
82import qualified System.IO as IO
82import qualified System.IO as IO
83
83
84−import Asyncly.Core
84+import Streamly.Core
85−import Asyncly.Streams
85+import Streamly.Streams
86
86
87------------------------------------------------------------------------------
87------------------------------------------------------------------------------
88-- Construction
88-- Construction
src/Asyncly/Streams.hs → src/Streamly/Streams.hsrenamed+3−3
@@ -7,7 +7,7 @@
7{-# LANGUAGE UndecidableInstances #-} -- XXX
7{-# LANGUAGE UndecidableInstances #-} -- XXX
8
8
9-- |
9-- |
10−-- Module : Asyncly.Streams
10+-- Module : Streamly.Streams
11-- Copyright : (c) 2017 Harendra Kumar
11-- Copyright : (c) 2017 Harendra Kumar
12--
12--
13-- License : BSD3
13-- License : BSD3
@@ -16,7 +16,7 @@
16-- Portability : GHC
16-- Portability : GHC
17--
17--
18--
18--
19−module Asyncly.Streams
19+module Streamly.Streams
20 (
20 (
21 -- * Product Style Composition
21 -- * Product Style Composition
22 -- $product
22 -- $product
@@ -97,7 +97,7 @@ import Control.Monad.State.Class (MonadState(..))
97import Control.Monad.Trans.Class (MonadTrans)
97import Control.Monad.Trans.Class (MonadTrans)
98import Data.Semigroup (Semigroup(..))
98import Data.Semigroup (Semigroup(..))
99import Prelude hiding (drop, take, zipWith)
99import Prelude hiding (drop, take, zipWith)
100−import Asyncly.Core
100+import Streamly.Core
101
101
102-- $product
102-- $product
103--
103--
src/Asyncly/Time.hs → src/Streamly/Time.hsrenamed+2−2
@@ -1,5 +1,5 @@
1-- |
1-- |
2−-- Module : Asyncly.Time
2+-- Module : Streamly.Time
3-- Copyright : (c) 2017 Harendra Kumar
3-- Copyright : (c) 2017 Harendra Kumar
4--
4--
5-- License : BSD3
5-- License : BSD3
@@ -9,7 +9,7 @@
9--
9--
10-- Time utilities for reactive programming.
10-- Time utilities for reactive programming.
11
11
12−module Asyncly.Time
12+module Streamly.Time
13 ( periodic
13 ( periodic
14 , withClock
14 , withClock
15 )
15 )
src/Asyncly/Tutorial.hs → src/Streamly/Tutorial.hsrenamed+25−25
@@ -1,12 +1,12 @@
1{-# OPTIONS_GHC -fno-warn-unused-imports #-}
1{-# OPTIONS_GHC -fno-warn-unused-imports #-}
2-- |
2-- |
3−-- Module : Asyncly.Tutorial
3+-- Module : Streamly.Tutorial
4-- Copyright : (c) 2017 Harendra Kumar
4-- Copyright : (c) 2017 Harendra Kumar
5--
5--
6-- License : BSD3
6-- License : BSD3
7-- Maintainer : harendra.kumar@gmail.com
7-- Maintainer : harendra.kumar@gmail.com
8--
8--
9−-- Asyncly combines streaming, logic programming, concurrency and reactive
9+-- Streamly combines streaming, logic programming, concurrency and reactive
10-- programming under a single abstraction with a concise API, giving
10-- programming under a single abstraction with a concise API, giving
11-- programmers a simple yet powerful tool for wide variety of applications.
11-- programmers a simple yet powerful tool for wide variety of applications.
12--
12--
@@ -26,18 +26,18 @@
26-- iterations of a loop, '>>|' runs iterations in parallel and '>|>' runs all
26-- iterations of a loop, '>>|' runs iterations in parallel and '>|>' runs all
27-- iterations in fairly parallel manner.
27-- iterations in fairly parallel manner.
28--
28--
29−-- With asyncly you can write concurrent and streaming applications without
29+-- With streamly you can write concurrent and streaming applications without
30-- being aware of threads or synchronization. No explicit thread control is
30-- being aware of threads or synchronization. No explicit thread control is
31-- needed, where applicable the concurrency rate is automatically controlled
31-- needed, where applicable the concurrency rate is automatically controlled
32-- based on the demand by the consumer. However, combinators are provided to
32-- based on the demand by the consumer. However, combinators are provided to
33-- fine tune the concurrency control. Streaming and concurrency allows
33-- fine tune the concurrency control. Streaming and concurrency allows
34−-- expressing reactive applications conveniently. See 'Asyncly.Examples' for a
34+-- expressing reactive applications conveniently. See 'Streamly.Examples' for a
35-- simple SDL based FRP example.
35-- simple SDL based FRP example.
36--
36--
37−-- For examples and other ways to use the library see 'Asyncly.Examples' as
37+-- For examples and other ways to use the library see 'Streamly.Examples' as
38-- well.
38-- well.
39--
39--
40−module Asyncly.Tutorial
40+module Streamly.Tutorial
41 (
41 (
42 -- * AsyncT Monad Transformer
42 -- * AsyncT Monad Transformer
43 -- $transformer
43 -- $transformer
@@ -116,9 +116,9 @@ module Asyncly.Tutorial
116 )
116 )
117where
117where
118
118
119−import Asyncly.Core
119+import Streamly.Core
120−import Asyncly.Prelude
120+import Streamly.Prelude
121−-- import Asyncly.Examples
121+-- import Streamly.Examples
122import Data.Semigroup
122import Data.Semigroup
123import Control.Applicative
123import Control.Applicative
124import Control.Monad
124import Control.Monad
@@ -156,7 +156,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
156-- to deconstruct an 'AsyncT' stream into head and tail.
156-- to deconstruct an 'AsyncT' stream into head and tail.
157--
157--
158-- @
158-- @
159−-- import Asyncly
159+-- import Streamly
160--
160--
161-- main = do
161-- main = do
162-- runAsyncly $ liftIO $ putStrLn "Hello world!"
162-- runAsyncly $ liftIO $ putStrLn "Hello world!"
@@ -174,7 +174,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
174-- specified by the argument in seconds and then prints the argument.
174-- specified by the argument in seconds and then prints the argument.
175--
175--
176-- @
176-- @
177−-- import Asyncly
177+-- import Streamly
178-- import Control.Concurrent
178-- import Control.Concurrent
179--
179--
180-- traced m = liftIO (myThreadId >>= print) >> m
180-- traced m = liftIO (myThreadId >>= print) >> m
@@ -289,7 +289,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
289-- name of the search engine as a response arrives:
289-- name of the search engine as a response arrives:
290--
290--
291-- @
291-- @
292−-- import Asyncly
292+-- import Streamly
293-- import Network.HTTP.Simple
293-- import Network.HTTP.Simple
294--
294--
295-- main = runAsyncly $ google \<|> bing \<|> duckduckgo
295-- main = runAsyncly $ google \<|> bing \<|> duckduckgo
@@ -309,7 +309,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
309-- Take an example of a merge sort of two sorted streams. We need to keep
309-- Take an example of a merge sort of two sorted streams. We need to keep
310-- consuming items from the stream which has the lowest item in the sort order.
310-- consuming items from the stream which has the lowest item in the sort order.
311-- This can be achieved using async references to streams. See
311-- This can be achieved using async references to streams. See
312−-- 'Asyncly.Examples.MergeSortedStreams'.
312+-- 'Streamly.Examples.MergeSortedStreams'.
313
313
314-- $monoid
314-- $monoid
315--
315--
@@ -324,7 +324,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
324-- the function argument.
324-- the function argument.
325--
325--
326-- @
326-- @
327−-- import Asyncly
327+-- import Streamly
328--
328--
329-- main = do
329-- main = do
330-- runAsyncly $ liftIO $ putStrLn "Hello world!"
330-- runAsyncly $ liftIO $ putStrLn "Hello world!"
@@ -352,7 +352,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
352-- all elements of the stream using 'fmap'.
352-- all elements of the stream using 'fmap'.
353--
353--
354-- @
354-- @
355−-- import Asyncly
355+-- import Streamly
356--
356--
357-- main = do
357-- main = do
358-- let nums = foldMapWith (<>) return [1..10]
358-- let nums = foldMapWith (<>) return [1..10]
@@ -395,7 +395,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
395-- loop:
395-- loop:
396--
396--
397-- @
397-- @
398−-- import Asyncly
398+-- import Streamly
399-- import Data.Semigroup (cycle1)
399-- import Data.Semigroup (cycle1)
400--
400--
401-- main = runAsyncly $ do
401-- main = runAsyncly $ do
@@ -430,7 +430,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
430-- example:
430-- example:
431--
431--
432-- @
432-- @
433−-- import Asyncly
433+-- import Streamly
434--
434--
435-- main = runAsyncly $
435-- main = runAsyncly $
436-- sizes >-> \\sz ->
436-- sizes >-> \\sz ->
@@ -449,7 +449,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
449-- $concurrentNesting
449-- $concurrentNesting
450--
450--
451-- @
451-- @
452−-- import Asyncly
452+-- import Streamly
453-- import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
453-- import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
454-- import Control.Concurrent
454-- import Control.Concurrent
455--
455--
@@ -476,7 +476,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
476-- $fairlyConcurrentNesting
476-- $fairlyConcurrentNesting
477--
477--
478-- @
478-- @
479−-- import Asyncly
479+-- import Streamly
480-- import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
480-- import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
481-- import Control.Concurrent
481-- import Control.Concurrent
482--
482--
@@ -516,7 +516,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
516-- sum and print them serially:
516-- sum and print them serially:
517--
517--
518-- @
518-- @
519−-- import Asyncly
519+-- import Streamly
520-- import Data.List (sum)
520-- import Data.List (sum)
521--
521--
522-- main = do
522-- main = do
@@ -529,7 +529,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
529-- monadic bind.
529-- monadic bind.
530--
530--
531-- @
531-- @
532−-- import Asyncly
532+-- import Streamly
533-- import Data.List (sum)
533-- import Data.List (sum)
534--
534--
535-- main = do
535-- main = do
@@ -544,7 +544,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
544-- Let us see a reactive programming example:
544-- Let us see a reactive programming example:
545--
545--
546-- @
546-- @
547−-- import Asyncly
547+-- import Streamly
548-- import Control.Concurrent (threadDelay)
548-- import Control.Concurrent (threadDelay)
549-- import Control.Monad (when)
549-- import Control.Monad (when)
550-- import Control.Monad.State
550-- import Control.Monad.State
@@ -588,13 +588,13 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
588
588
589-- $comparison
589-- $comparison
590--
590--
591−-- Even though asyncly covers all that is provided by the 'async' package or
591+-- Even though streamly covers all that is provided by the 'async' package or
592-- most of what is provided by the 'streaming', 'pipes' or 'conduit' packages,
592-- most of what is provided by the 'streaming', 'pipes' or 'conduit' packages,
593−-- I would not say that it renders those useless. Asyncly is like monad if
593+-- I would not say that it renders those useless. Streamly is like monad if
594-- 'async' is applicative and monads and applicatives both have their use
594-- 'async' is applicative and monads and applicatives both have their use
595-- cases. It can completely repalce 'async', the ZipAsync type is equivalent to
595-- cases. It can completely repalce 'async', the ZipAsync type is equivalent to
596-- the functionality provided by 'async'.
596-- the functionality provided by 'async'.
597--
597--
598−-- pipes and conduit are like Arrows and asyncly is like monad to them. You
598+-- pipes and conduit are like Arrows and streamly is like monad to them. You
599-- would use pipes and conduit when you do not need the product style
599-- would use pipes and conduit when you do not need the product style
600-- composition and the implicit concurrency.
600-- composition and the implicit concurrency.
asyncly.cabal → streamly.cabalrenamed+28−28
@@ -1,17 +1,17 @@
1−name: asyncly
1+name: streamly
2version: 0.1.0
2version: 0.1.0
3synopsis: Beautiful Streaming, Concurrent and Reactive Composition
3synopsis: Beautiful Streaming, Concurrent and Reactive Composition
4−description: Asyncly is a general streaming and concurrent programming
4+description: Streamly is a general streaming and concurrent programming
5 monad allowing you to write a wide variety of applications ranging from
5 monad allowing you to write a wide variety of applications ranging from
6 simple applications utilizing streaming IO to massively parallel concurrent
6 simple applications utilizing streaming IO to massively parallel concurrent
7 applications as well as reactive (FRP) applications with the same ease.
7 applications as well as reactive (FRP) applications with the same ease.
8− Asyncly provides high level concurrency primitives and hides the low level
8+ Streamly provides high level concurrency primitives and hides the low level
9 concurrency details completely from the programmer. The programmer just
9 concurrency details completely from the programmer. The programmer just
10 expresses whether a task can run in parallel with another. Threads,
10 expresses whether a task can run in parallel with another. Threads,
11 synchronization and concurrency rate control are handled automatically. The
11 synchronization and concurrency rate control are handled automatically. The
12 library has been written keeping high performance applications in mind.
12 library has been written keeping high performance applications in mind.
13 .
13 .
14− Asyncly subsumes all the use cases of list transformer (list-t) and logic
14+ Streamly subsumes all the use cases of list transformer (list-t) and logic
15 programming (logict) monads and adds concurrency on top. It is a streaming
15 programming (logict) monads and adds concurrency on top. It is a streaming
16 library and therefore can be used for most of the streaming use cases as well
16 library and therefore can be used for most of the streaming use cases as well
17 (i.e. where you would use conduit or pipes) with concurrency added. It is
17 (i.e. where you would use conduit or pipes) with concurrency added. It is
@@ -25,20 +25,20 @@ description: Asyncly is a general streaming and concurrent programming
25 a directory tree:
25 a directory tree:
26 .
26 .
27 > import Path.IO (listDir, getCurrentDir)
27 > import Path.IO (listDir, getCurrentDir)
28− > import Asyncly
28+ > import Streamly
29 >
29 >
30− > main = runAsyncly $ getCurrentDir >>= readdir
30+ > main = runStreamly $ getCurrentDir >>= readdir
31 > where readdir d = do
31 > where readdir d = do
32 > (dirs, files) <- lift $ listDir d
32 > (dirs, files) <- lift $ listDir d
33 > liftIO $ mapM_ putStrLn $ map show files
33 > liftIO $ mapM_ putStrLn $ map show files
34 > foldMapWith (<|>) readdir dirs
34 > foldMapWith (<|>) readdir dirs
35 .
35 .
36− See "Asyncly.Tutorial" and "Asyncly.Examples" for more details.
36+ See "Streamly.Tutorial" and "Streamly.Examples" for more details.
37 .
37 .
38 This library was originally inspired by the `transient`
38 This library was originally inspired by the `transient`
39 package authored by Alberto G. Corona.
39 package authored by Alberto G. Corona.
40−homepage: http://github.com/harendra-kumar/asyncly
40+homepage: http://github.com/harendra-kumar/streamly
41−bug-reports: https://github.com/harendra-kumar/asyncly/issues
41+bug-reports: https://github.com/harendra-kumar/streamly/issues
42license: BSD3
42license: BSD3
43license-file: LICENSE
43license-file: LICENSE
44author: Harendra Kumar
44author: Harendra Kumar
@@ -51,7 +51,7 @@ cabal-version: >= 1.10
51
51
52source-repository head
52source-repository head
53 type: git
53 type: git
54− location: https://github.com/harendra-kumar/asyncly
54+ location: https://github.com/harendra-kumar/streamly
55
55
56flag dev
56flag dev
57 description: Build development version
57 description: Build development version
@@ -70,18 +70,18 @@ flag examples
70
70
71library
71library
72 hs-source-dirs: src
72 hs-source-dirs: src
73− exposed-modules: Asyncly.Core
73+ exposed-modules: Streamly.Core
74− , Asyncly.Streams
74+ , Streamly.Streams
75− , Asyncly.Prelude
75+ , Streamly.Prelude
76− , Asyncly.Time
76+ , Streamly.Time
77− , Asyncly.Tutorial
77+ , Streamly.Tutorial
78− , Asyncly
78+ , Streamly
79 if flag(examples)
79 if flag(examples)
80− exposed-modules: Asyncly.Examples.SearchEngineQuery
80+ exposed-modules: Streamly.Examples.SearchEngineQuery
81− , Asyncly.Examples.ListDirRecursive
81+ , Streamly.Examples.ListDirRecursive
82− , Asyncly.Examples.MergeSortedStreams
82+ , Streamly.Examples.MergeSortedStreams
83− , Asyncly.Examples.AcidRainGame
83+ , Streamly.Examples.AcidRainGame
84− , Asyncly.Examples.CirclingSquare
84+ , Streamly.Examples.CirclingSquare
85
85
86 default-language: Haskell2010
86 default-language: Haskell2010
87 ghc-options: -Wall
87 ghc-options: -Wall
@@ -141,7 +141,7 @@ test-suite test
141 -Wnoncanonical-monad-instances
141 -Wnoncanonical-monad-instances
142 -Wnoncanonical-monadfail-instances
142 -Wnoncanonical-monadfail-instances
143 build-depends:
143 build-depends:
144− asyncly
144+ streamly
145 , base >= 4.8 && < 5
145 , base >= 4.8 && < 5
146 , hspec >= 2.0 && < 3
146 , hspec >= 2.0 && < 3
147 , containers >= 0.5 && < 0.6
147 , containers >= 0.5 && < 0.6
@@ -169,7 +169,7 @@ benchmark bench
169 -Wnoncanonical-monad-instances
169 -Wnoncanonical-monad-instances
170 -Wnoncanonical-monadfail-instances
170 -Wnoncanonical-monadfail-instances
171 build-depends:
171 build-depends:
172− asyncly
172+ streamly
173 , atomic-primops >= 0.8 && < 0.9
173 , atomic-primops >= 0.8 && < 0.9
174 , base >= 4.8 && < 5
174 , base >= 4.8 && < 5
175 , criterion >= 1 && < 2
175 , criterion >= 1 && < 2
@@ -199,7 +199,7 @@ executable echo-loop
199 if flag(examples)
199 if flag(examples)
200 buildable: True
200 buildable: True
201 build-Depends:
201 build-Depends:
202− asyncly
202+ streamly
203 , base >= 4.8 && < 5
203 , base >= 4.8 && < 5
204 else
204 else
205 buildable: False
205 buildable: False
@@ -210,7 +210,7 @@ executable loops
210 if flag(examples)
210 if flag(examples)
211 buildable: True
211 buildable: True
212 build-Depends:
212 build-Depends:
213− asyncly
213+ streamly
214 , base >= 4.8 && < 5
214 , base >= 4.8 && < 5
215 else
215 else
216 buildable: False
216 buildable: False
@@ -221,7 +221,7 @@ executable map-reduce
221 if flag(examples)
221 if flag(examples)
222 buildable: True
222 buildable: True
223 build-Depends:
223 build-Depends:
224− asyncly
224+ streamly
225 , base >= 4.8 && < 5
225 , base >= 4.8 && < 5
226 else
226 else
227 buildable: False
227 buildable: False
@@ -232,7 +232,7 @@ executable nested-loops
232 if flag(examples)
232 if flag(examples)
233 buildable: True
233 buildable: True
234 build-Depends:
234 build-Depends:
235− asyncly
235+ streamly
236 , base >= 4.8 && < 5
236 , base >= 4.8 && < 5
237 , random
237 , random
238 else
238 else
@@ -244,7 +244,7 @@ executable parallel-loops
244 if flag(examples)
244 if flag(examples)
245 buildable: True
245 buildable: True
246 build-Depends:
246 build-Depends:
247− asyncly
247+ streamly
248 , base >= 4.8 && < 5
248 , base >= 4.8 && < 5
249 , random
249 , random
250 else
250 else
test/Main.hs+3−3
@@ -8,8 +8,8 @@ import Data.Foldable (forM_)
8import Data.List (sort)
8import Data.List (sort)
9import Test.Hspec
9import Test.Hspec
10
10
11−import Asyncly
11+import Streamly
12−import qualified Asyncly.Prelude as A
12+import qualified Streamly.Prelude as A
13
13
14toListSerial :: StreamT IO a -> IO [a]
14toListSerial :: StreamT IO a -> IO [a]
15toListSerial = A.toList . serially
15toListSerial = A.toList . serially
@@ -385,7 +385,7 @@ timed x = liftIO (threadDelay (x * 100000)) >> return x
385
385
386thenBind :: Spec
386thenBind :: Spec
387thenBind = do
387thenBind = do
388− it "Simple runAsyncly and 'then' with IO" $
388+ it "Simple runStreaming and 'then' with IO" $
389 (runStreaming . serially) (liftIO (putStrLn "hello") >> liftIO (putStrLn "world"))
389 (runStreaming . serially) (liftIO (putStrLn "hello") >> liftIO (putStrLn "world"))
390 `shouldReturn` ()
390 `shouldReturn` ()
391 it "Then and toList" $
391 it "Then and toList" $