Stream 0.2.3 → 0.2.4
raw patch · 2 files changed
+10/−3 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Stream: instance (Ord a) => Ord (Stream a)
Files
- Data/Stream.hs +9/−2
- Stream.cabal +1/−1
Data/Stream.hs view
@@ -62,8 +62,12 @@ import Test.QuickCheck -- | An infinite sequence.-data Stream a = Cons a (Stream a) deriving (Show, Eq)+--+-- /Beware/: If you use any function from the @ Eq @ or @ Ord @+-- class two compare to equal streams, these functions will diverge. +data Stream a = Cons a (Stream a) deriving (Eq, Ord, Show)+ infixr 5 `Cons` instance Functor Stream where@@ -75,7 +79,10 @@ instance Monad Stream where return = repeat- (Cons x xs) >>= f = Cons (head (f x)) (tail (xs >>= f))+ xs >>= f = join (fmap f xs)+ where+ join :: Stream (Stream a) -> Stream a+ join (Cons xs xss) = Cons (head xs) (join (map tail xss)) instance Arbitrary a => Arbitrary (Stream a) where arbitrary = liftM2 Cons arbitrary arbitrary
Stream.cabal view
@@ -1,5 +1,5 @@ Name: Stream-Version: 0.2.3+Version: 0.2.4 License: BSD3 License-file: LICENSE Author: Wouter Swierstra