2-- Module : BenchmarkOps
3-- Copyright : (c) 2018 Harendra Kumar
6-- Maintainer : harendra.kumar@gmail.com
8{-# LANGUAGE FlexibleContexts #-}
9{-# LANGUAGE ScopedTypeVariables #-}
13import Control.Exception (try)
14import GHC.Exception (ErrorCall)
16import qualified Streamly as S
17import qualified Streamly.Prelude as S
25-------------------------------------------------------------------------------
26-- Stream generation and elimination
27-------------------------------------------------------------------------------
29type Stream m a = S.SerialT m a
32source :: (S.MonadAsync m, S.IsStream t) => Int -> Int -> t m Int
33source = sourceUnfoldrM
35{-# INLINE sourceUnfoldrM #-}
36sourceUnfoldrM :: (S.IsStream t, S.MonadAsync m) => Int -> Int -> t m Int
37sourceUnfoldrM n value = S.serially $ S.unfoldrM step n
42 else return (Just (cnt, cnt + 1))
44{-# INLINE sourceUnfoldr #-}
45sourceUnfoldr :: (Monad m, S.IsStream t) => Int -> Int -> t m Int
46sourceUnfoldr start n = S.unfoldr step start
51 else Just (cnt, cnt + 1)
53{-# INLINE runStream #-}
54runStream :: Monad m => Stream m a -> m ()
55runStream = S.runStream
57{-# INLINE runToList #-}
58runToList :: Monad m => Stream m a -> m [a]
61-------------------------------------------------------------------------------
63-------------------------------------------------------------------------------
67 :: (S.IsStream t, S.MonadAsync m, Monad (t m))
68 => (t m Int -> S.SerialT m Int) -> Int -> m ()
69toNull t start = runStream . t $ do
70 x <- source start prodCount
71 y <- source start prodCount
76 :: (S.IsStream t, S.MonadAsync m, Monad (t m))
77 => (t m Int -> S.SerialT m Int) -> Int -> m [Int]
78toList t start = runToList . t $ do
79 x <- source start prodCount
80 y <- source start prodCount
83{-# INLINE toListSome #-}
85 :: (S.IsStream t, S.MonadAsync m, Monad (t m))
86 => (t m Int -> S.SerialT m Int) -> Int -> m [Int]
88 runToList . t $ S.take 1000 $ do
89 x <- source start prodCount
90 y <- source start prodCount
93{-# INLINE filterAllOut #-}
95 :: (S.IsStream t, S.MonadAsync m, Monad (t m))
96 => (t m Int -> S.SerialT m Int) -> Int -> m ()
97filterAllOut t start = runStream . t $ do
98 x <- source start prodCount
99 y <- source start prodCount
105{-# INLINE filterAllIn #-}
107 :: (S.IsStream t, S.MonadAsync m, Monad (t m))
108 => (t m Int -> S.SerialT m Int) -> Int -> m ()
109filterAllIn t start = runStream . t $ do
110 x <- source start prodCount
111 y <- source start prodCount
117{-# INLINE filterSome #-}
119 :: (S.IsStream t, S.MonadAsync m, Monad (t m))
120 => (t m Int -> S.SerialT m Int) -> Int -> m ()
121filterSome t start = runStream . t $ do
122 x <- source start prodCount
123 y <- source start prodCount
129{-# INLINE breakAfterSome #-}
131 :: (S.IsStream t, Monad (t IO))
132 => (t IO Int -> S.SerialT IO Int) -> Int -> IO ()
133breakAfterSome t start = do
134 (_ :: Either ErrorCall ()) <- try $ runStream . t $ do
135 x <- source start prodCount
136 y <- source start prodCount
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