on master help sign in
Derive Foldable and Traversable instance for all the newtype wrappers around streams
159a0d2Abhiroop Sarkar
src/Streamly/Streams/Ahead.hs+2−1
@@ -1,5 +1,6 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE ConstraintKinds #-}
3+{-# LANGUAGE DeriveTraversable #-}
3{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE GeneralizedNewtypeDeriving#-}
6{-# LANGUAGE GeneralizedNewtypeDeriving#-}
@@ -619,7 +620,7 @@ consMAhead m r = K.yieldM m `aheadS` r
619--
620--
620-- @since 0.3.0
621-- @since 0.3.0
621newtype AheadT m a = AheadT {getAheadT :: Stream m a}
622newtype AheadT m a = AheadT {getAheadT :: Stream m a}
622− deriving (MonadTrans)
623+ deriving (MonadTrans, Foldable, Traversable)
623
624
624-- | A serial IO stream of elements of type @a@ with concurrent lookahead. See
625-- | A serial IO stream of elements of type @a@ with concurrent lookahead. See
625-- 'AheadT' documentation for more details.
626-- 'AheadT' documentation for more details.
src/Streamly/Streams/Async.hs+3−2
@@ -1,5 +1,6 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE ConstraintKinds #-}
3+{-# LANGUAGE DeriveTraversable #-}
3{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE GeneralizedNewtypeDeriving#-}
6{-# LANGUAGE GeneralizedNewtypeDeriving#-}
@@ -635,7 +636,7 @@ consMAsync m r = K.yieldM m `asyncS` r
635--
636--
636-- @since 0.1.0
637-- @since 0.1.0
637newtype AsyncT m a = AsyncT {getAsyncT :: Stream m a}
638newtype AsyncT m a = AsyncT {getAsyncT :: Stream m a}
638− deriving (MonadTrans)
639+ deriving (MonadTrans, Foldable, Traversable)
639
640
640-- | A demand driven left biased parallely composing IO stream of elements of
641-- | A demand driven left biased parallely composing IO stream of elements of
641-- type @a@. See 'AsyncT' documentation for more details.
642-- type @a@. See 'AsyncT' documentation for more details.
@@ -762,7 +763,7 @@ wAsync m1 m2 = fromStream $ Stream $ \st stp sng yld ->
762--
763--
763-- @since 0.2.0
764-- @since 0.2.0
764newtype WAsyncT m a = WAsyncT {getWAsyncT :: Stream m a}
765newtype WAsyncT m a = WAsyncT {getWAsyncT :: Stream m a}
765− deriving (MonadTrans)
766+ deriving (MonadTrans, Foldable, Traversable)
766
767
767-- | A round robin parallely composing IO stream of elements of type @a@.
768-- | A round robin parallely composing IO stream of elements of type @a@.
768-- See 'WAsyncT' documentation for more details.
769-- See 'WAsyncT' documentation for more details.
src/Streamly/Streams/Parallel.hs+2−1
@@ -1,5 +1,6 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE ConstraintKinds #-}
3+{-# LANGUAGE DeriveTraversable #-}
3{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE GeneralizedNewtypeDeriving#-}
6{-# LANGUAGE GeneralizedNewtypeDeriving#-}
@@ -325,7 +326,7 @@ x |&. f = f |$. x
325--
326--
326-- @since 0.1.0
327-- @since 0.1.0
327newtype ParallelT m a = ParallelT {getParallelT :: Stream m a}
328newtype ParallelT m a = ParallelT {getParallelT :: Stream m a}
328− deriving (MonadTrans)
329+ deriving (MonadTrans, Foldable, Traversable)
329
330
330-- | A parallely composing IO stream of elements of type @a@.
331-- | A parallely composing IO stream of elements of type @a@.
331-- See 'ParallelT' documentation for more details.
332-- See 'ParallelT' documentation for more details.
src/Streamly/Streams/Serial.hs+3−2
@@ -1,5 +1,6 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE ConstraintKinds #-}
3+{-# LANGUAGE DeriveTraversable #-}
3{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE GeneralizedNewtypeDeriving#-}
6{-# LANGUAGE GeneralizedNewtypeDeriving#-}
@@ -121,7 +122,7 @@ import qualified Streamly.Streams.StreamD as D
121--
122--
122-- @since 0.2.0
123-- @since 0.2.0
123newtype SerialT m a = SerialT {getSerialT :: Stream m a}
124newtype SerialT m a = SerialT {getSerialT :: Stream m a}
124− deriving (Semigroup, Monoid, MonadTrans)
125+ deriving (Semigroup, Monoid, MonadTrans, Foldable, Traversable)
125
126
126-- | A serial IO stream of elements of type @a@. See 'SerialT' documentation
127-- | A serial IO stream of elements of type @a@. See 'SerialT' documentation
127-- for more details.
128-- for more details.
@@ -241,7 +242,7 @@ MONAD_COMMON_INSTANCES(SerialT,)
241--
242--
242-- @since 0.2.0
243-- @since 0.2.0
243newtype WSerialT m a = WSerialT {getWSerialT :: Stream m a}
244newtype WSerialT m a = WSerialT {getWSerialT :: Stream m a}
244− deriving (MonadTrans)
245+ deriving (MonadTrans, Foldable, Traversable)
245
246
246-- | An interleaving serial IO stream of elements of type @a@. See 'WSerialT'
247-- | An interleaving serial IO stream of elements of type @a@. See 'WSerialT'
247-- documentation for more details.
248-- documentation for more details.
src/Streamly/Streams/Zip.hs+3−2
@@ -1,5 +1,6 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE ConstraintKinds #-}
3+{-# LANGUAGE DeriveTraversable #-}
3{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE GeneralizedNewtypeDeriving#-}
6{-# LANGUAGE GeneralizedNewtypeDeriving#-}
@@ -72,7 +73,7 @@ import qualified Streamly.Streams.StreamK as K
72--
73--
73-- @since 0.2.0
74-- @since 0.2.0
74newtype ZipSerialM m a = ZipSerialM {getZipSerialM :: Stream m a}
75newtype ZipSerialM m a = ZipSerialM {getZipSerialM :: Stream m a}
75− deriving (Semigroup, Monoid)
76+ deriving (Semigroup, Monoid, Foldable, Traversable)
76
77
77-- |
78-- |
78-- @since 0.1.0
79-- @since 0.1.0
@@ -166,7 +167,7 @@ zipAsyncWithM f m1 m2 = fromStream $ Stream $ \st stp sng yld -> do
166--
167--
167-- @since 0.2.0
168-- @since 0.2.0
168newtype ZipAsyncM m a = ZipAsyncM {getZipAsyncM :: Stream m a}
169newtype ZipAsyncM m a = ZipAsyncM {getZipAsyncM :: Stream m a}
169− deriving (Semigroup, Monoid)
170+ deriving (Semigroup, Monoid, Foldable, Traversable)
170
171
171-- | An IO stream whose applicative instance zips streams wAsyncly.
172-- | An IO stream whose applicative instance zips streams wAsyncly.
172--
173--