on master help sign in
Update tutorial with performance and interop details
73e33aeHarendra Kumar
src/Streamly/Tutorial.hs+70−7
@@ -109,14 +109,11 @@ module Streamly.Tutorial
109 -- * Reactive Programming
109 -- * Reactive Programming
110 -- $reactive
110 -- $reactive
111
111
112− -- * State Machine Model
113− -- $statemachine
114−
115 -- * Performance
112 -- * Performance
116 -- $performance
113 -- $performance
117
114
118− -- * Interworking with Streaming Libraries
115+ -- * Interoperation with Streaming Libraries
119− -- $interwork
116+ -- $interop
120
117
121 -- * Comparison with Existing Packages
118 -- * Comparison with Existing Packages
122 -- $comparison
119 -- $comparison
@@ -872,8 +869,74 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
872-- concurrency in streamly. You can also find a SDL based reactive programming
869-- concurrency in streamly. You can also find a SDL based reactive programming
873-- example adapted from Yampa in "Streamly.Examples.CirclingSquare".
870-- example adapted from Yampa in "Streamly.Examples.CirclingSquare".
874
871
875−-- $statemachine
872+-- $performance
876−-- State machine stuff
873+--
874+-- Streamly is highly optimized for performance, it is designed for serious
875+-- high performing, concurrent and scalable applications. We have created the
876+-- <https://hackage.haskell.org/package/streaming-benchmarks streaming-benchmarks>
877+-- package which is specifically and carefully designed to measure the
878+-- performance of Haskell streaming libraries fairly and squarely in the right
879+-- way. Streamly performs at par or even better than most streaming libraries
880+-- for common operations even though it needs to deal with the concurrency
881+-- capability.
882+
883+-- $interop
884+--
885+-- We can use @unfoldr@ and @uncons@ to convert one streaming type to another.
886+-- We will assume the following common code to be available in the examples
887+-- demonstrated below.
888+--
889+-- @
890+-- import Streamly
891+-- import Streamly.Prelude
892+-- import System.IO (stdin)
893+--
894+-- -- Adapt uncons to return an Either instead of Maybe
895+-- unconsE s = 'uncons' s >>= maybe (return $ Left ()) (return . Right)
896+-- stdinLn = 'serially' $ 'fromHandle' stdin
897+-- @
898+--
899+-- Interop with @pipes@:
900+--
901+-- @
902+-- import qualified Pipes as P
903+-- import qualified Pipes.Prelude as P
904+--
905+-- main = do
906+-- -- streamly to pipe
907+-- P.runEffect $ P.for (P.unfoldr unconsE stdinLn) (lift . putStrLn)
908+--
909+-- -- pipe to streamly
910+-- -- Adapt P.next to return a Maybe instead of Either
911+-- let nextM p = P.next p >>= either (\\_ -> return Nothing) (return . Just)
912+-- runStreamT $ unfoldrM nextM P.stdinLn >>= lift . putStrLn
913+-- @
914+--
915+-- Interop with @streaming@:
916+--
917+-- @
918+-- import qualified Streaming as S
919+-- import qualified Streaming.Prelude as S
920+--
921+-- main = do
922+-- -- streamly to streaming
923+-- S.stdoutLn $ S.unfoldr unconsE stdinLn
924+--
925+-- -- streaming to streamly
926+-- runStreamT $ unfoldrM S.uncons S.stdinLn >>= lift . putStrLn
927+--
928+-- @
929+--
930+-- Interop with @conduit@:
931+--
932+-- @
933+-- import qualified Data.Conduit as C
934+-- import qualified Data.Conduit.List as C
935+-- import qualified Data.Conduit.Combinators as C
936+--
937+-- -- streamly to conduit
938+-- main = (C.unfoldM 'uncons' stdinLn) C.$$ C.print
939+-- @
877
940
878-- $comparison
941-- $comparison
879--
942--