Stream 0.4.6 → 0.4.6.1
raw patch · 2 files changed
+36/−6 lines, 2 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Data.Stream: unzip3 :: Stream (a, b, c) -> (Stream a, Stream b, Stream c)
+ Data.Stream: zip3 :: Stream a -> Stream b -> Stream c -> Stream (a, b, c)
+ Data.Stream: zipWith3 :: (a -> b -> c -> d) -> Stream a -> Stream b -> Stream c -> Stream d
Files
- Data/Stream.hs +34/−4
- Stream.cabal +2/−2
Data/Stream.hs view
@@ -48,6 +48,9 @@ , zip , zipWith , unzip+ , zip3+ , zipWith3+ , unzip3 -- * Functions on streams of characters , words , unwords@@ -61,8 +64,9 @@ import Prelude hiding (head, tail, map, scanl, scanl1, iterate, take, drop, takeWhile,- dropWhile, repeat, cycle, filter, (!!), zip, unzip,- zipWith,words,unwords,lines,unlines, break, span, splitAt)+ dropWhile, repeat, cycle, filter, (!!), + zip, unzip, zipWith, zip3, unzip3, zipWith3,+ words,unwords,lines,unlines, break, span, splitAt) import Control.Applicative import Control.Monad (liftM2)@@ -373,21 +377,47 @@ let ixs = (indicesFrom $! (ix+1)) xs in if p x then Cons ix ixs else ixs --- | The 'zip' function takes two streams and returns a list of--- corresponding pairs.+-- | The 'zip' function takes two streams and returns the stream of+-- pairs obtained by pairing elements at the same position in both+-- argument streams. zip :: Stream a -> Stream b -> Stream (a,b) zip ~(Cons x xs) ~(Cons y ys) = Cons (x,y) (zip xs ys) +-- | The 'zip3' function behaves as the 'zip' function, but works on+-- three streams.+zip3 :: Stream a -> Stream b -> Stream c -> Stream (a,b,c)+zip3 ~(Cons x xs) ~(Cons y ys) ~(Cons z zs) = Cons (x,y,z) (zip3 xs ys zs)+ -- | The 'zipWith' function generalizes 'zip'. Rather than tupling -- the functions, the elements are combined using the function -- passed as the first argument to 'zipWith'. zipWith :: (a -> b -> c) -> Stream a -> Stream b -> Stream c zipWith f ~(Cons x xs) ~(Cons y ys) = Cons (f x y) (zipWith f xs ys) +-- | The 'zipWith3' behaves as 'zipWith' but takes three stream+-- arguments.+zipWith3 :: (a -> b -> c -> d) -> Stream a -> Stream b -> Stream c -> Stream d+zipWith3 f ~(Cons x xs) ~(Cons y ys) (Cons z zs) = Cons (f x y z) (zipWith3 f xs ys zs)++ -- | The 'unzip' function is the inverse of the 'zip' function. unzip :: Stream (a,b) -> (Stream a, Stream b) unzip ~(Cons (x,y) xys) = (Cons x (fst (unzip xys)), Cons y (snd (unzip xys)))++-- | The 'unzip3' function is the inverse of the 'zip' function.+unzip3 :: Stream (a,b,c) -> (Stream a, Stream b, Stream c)+unzip3 ~(Cons (x,y,z) xyzs) = ( Cons x (fst3 (unzip3 xyzs))+ , Cons y (snd3 (unzip3 xyzs))+ , Cons z (thd3 (unzip3 xyzs)))+ where+ fst3 :: (a,b,c) -> a+ fst3 (x,_,_) = x + snd3 :: (a,b,c) -> b+ snd3 (_,y,_) = y+ thd3 :: (a,b,c) -> c + thd3 (_,_,z) = z+ -- | The 'words' function breaks a stream of characters into a -- stream of words, which were delimited by white space.
Stream.cabal view
@@ -1,10 +1,10 @@ Name: Stream-Version: 0.4.6+Version: 0.4.6.1 License: BSD3 License-file: LICENSE Author: Wouter Swierstra <wouter.swierstra@gmail.com> Bas van Dijk <v.dijk.bas@gmail.com>-Maintainer: Wouter Swierstra <wss@cs.nott.ac.uk>+Maintainer: Wouter Swierstra <wouter.swierstra@gmail.com> Stability: experimental Synopsis: A library for manipulating infinite lists. Description: This package implements functions, analogous