packages feed

streaming 0.1.3.2 → 0.1.3.3

raw patch · 2 files changed

+18/−9 lines, 2 files

Files

Streaming.hs view
@@ -1,7 +1,7 @@ {-#LANGUAGE RankNTypes #-} module Streaming     (-   -- * Free monad transformer+   -- * An iterable streaming monad transformer    -- $stream    Stream,     -- * Constructing a 'Stream' on a given functor@@ -92,14 +92,16 @@     The 'Stream' data type can be used to represent any effectful     succession of steps arising in some monad.      The form of the steps is specified by the first (\"functor\") -    parameter in @Stream f m r@, the monad of effects by the second.+    parameter in @Stream f m r@. The monad of the underlying effects +    is expressed by the second parameter. +     This module exports combinators that pertain to that general case.     Some of these are quite abstract and pervade any use of the library,      e.g.   >   maps ::   (forall x . f x -> g x)     -> Stream f m r -> Stream g m r   >   mapped :: (forall x . f x -> m (g x)) -> Stream f m r -> Stream g m r  ->   hoist :: (forall x . m x -> n x) -> Stream f m r -> Stream f n r+>   hoist :: (forall x . m x -> n x) -> Stream f m r -> Stream f n r -- via MFunctor >   concats :: Stream (Stream f m) m r -> Stream f m r                           (assuming here and thoughout that @m@ or @n@ satisfies a @Monad@ constraint, and@@ -108,21 +110,28 @@     Others are surprisingly determinate in content:  >   chunksOf :: Int -> Stream f m r -> Stream (Stream f m) m r->   splits :: -+>   splitsAt ::  Int -> Stream f m r -> Stream f m (Stream f m r)+>   zipsWith :: (forall x y. f x -> g y -> h (x, y)) -> Stream f m r -> Stream g m r -> Stream h m r+>   intercalates :: Stream f m () -> Stream (Stream f m) m r -> Stream f m r+>   groups: Stream (Sum f g) m r -> Stream (Sum (Stream f m) (Stream g m)) m r      One way to see that /any/ streaming library needs some such general type is     that it is required to represent the segmentation of a stream, and to     express the equivalents of @Prelude/Data.List@ combinators that involve-    'lists of lists' and the like.  The module @Streaming.Prelude@ exports-    combinators relating to +    'lists of lists' and the like. See for example this +    <http://www.haskellforall.com/2013/09/perfect-streaming-using-pipes-bytestring.html post> +    on the correct expression of a streaming \'lines\' function.  +    The module @Streaming.Prelude@ exports combinators relating to + > Stream (Of a) m r      where @Of a r = !a :> r@ is a left-strict pair. -> mapped Streaming.Prelude.length :: Stream (Stream (Of a) m) r -> Stream (Of Int) m r +   This expresses the concept of a 'Producer' or 'Source' or 'Generator' and+   easily inter-operates with types with such names in e.g. 'conduit', +   'iostreams' and 'pipes'. -}  {-| Map a stream to its church encoding; compare @Data.List.foldr@
streaming.cabal view
@@ -1,5 +1,5 @@ name:                streaming-version:             0.1.3.2+version:             0.1.3.3 cabal-version:       >=1.10 build-type:          Simple synopsis:            an elementary streaming prelude and a general stream type.