packages feed

quiver 1.0.1 → 1.0.2

raw patch · 3 files changed

+94/−26 lines, 3 files

Files

quiver.cabal view
@@ -1,5 +1,5 @@ name:               quiver-version:            1.0.1+version:            1.0.2 synopsis:           Quiver finite stream processing library homepage:           https://github.com/zadarnowski/quiver category:           Control@@ -34,7 +34,7 @@ source-repository this   type:     git   location: https://github.com/zadarnowski/quiver.git-  tag:      1.0.1+  tag:      1.0.2  library   hs-source-dirs:   src
src/Control/Quiver.lhs view
@@ -22,13 +22,13 @@ >   qlift, qhoist, qembed, >   qpure, qid, qconcat, >   runEffect,->   (>>->), (>->>), (>&>),+>   (>>->), (>->>), (+>>->), (>>->+), (+>->>), (>->>+), (>&>), >   qcompose, > ) where  > import Control.Quiver.Internal -> infixl 1 >>->, >->>, >&>+> infixl 1 >>->, >->>, +>>->, >>->+, +>->>, >->>+, >&>  > -- | @fetch x@ represents a singleton stream processor that > --   sends the request value @x@ upstream and delivers the@@ -103,7 +103,7 @@ >   loop (Enclose f)     = f >>= loop >   loop (Deliver r)     = return r -> -- | The @>>->@ represents a push-based composition of stream processor.+> -- | The @>>->@ represents a push-based composition of stream processors. > --   @p1 >>-> p2@ represents a stream processor that forwards the output > --   of @p1@ to @p2@, delivering the result of both processors. > --   The new processor is /driven/ by @p2@, so, if the base functor@@ -114,38 +114,106 @@ > (Consume x1 k1 q1) >>-> p2 = consume x1 ((>>-> p2) . k1) (q1 >>-> p2) > (Produce y1 k1 q1) >>-> p2 = loop p2 >  where->   loop  (Consume x2 k2  _) = k1 x2 >>-> k2 y1->   loop  (Produce y2 k2 q2) = produce y2 (loop . k2) (loop' q2)->   loop  (Enclose f2)       = enclose (fmap loop f2)->   loop  (Deliver r2)       = fmap (, r2) q1->   loop' (Consume x2 k2  _) = k1 x2 >>-> k2 y1->   loop' (Produce  _  _ q2) = loop' q2->   loop' (Enclose f2)       = enclose (fmap loop' f2)->   loop' (Deliver r2)       = fmap (, r2) q1+>   loop (Consume x2 k2  _) = k1 x2 >>-> k2 y1+>   loop (Produce y2 k2 q2) = produce y2 (loop . k2) (deplete $ loop q2)+>   loop (Enclose f2)       = enclose (fmap loop f2)+>   loop (Deliver r2)       = fmap (, r2) q1 > (Enclose f1) >>-> p2 = enclose (fmap (>>-> p2) f1) > (Deliver r1) >>-> p2 = fmap (r1 ,) (decouple p2) -> -- | The @>->>@ represents a pull-based composition of stream processor.+> -- | The @+>>->@ represents a pull-based composition of stream processors+> --   that is partial on the left (supply) side, so that @p1 +>>-> p2@+> --   represents a stream processor that forwards the output of @p1@ to @p2@,+> --   delivering the result of @p2@ and the remainder (unconsumed portion)+> --   of @p1@. The new processor is /driven/ by @p1@, so, if the base functor+> --   represents a non-commutative monad, any effects of @p1@ will be observed+> --   before those of @p2@.++> (+>>->) :: Functor f => P a a' b b' f r1 -> P b' b c c' f r2 -> P a a' c c' f (P a a' b b' f r1, r2)+> (Consume x1 k1 q1) +>>-> p2 = consume x1 ((+>>-> p2) . k1) (decouple $ q1 +>>-> p2)+> (Produce y1 k1 q1) +>>-> p2 = loop p2+>  where+>   loop (Consume x2 k2  _) = k1 x2 +>>-> k2 y1+>   loop (Produce y2 k2 q2) = produce y2 (loop . k2) (deplete $ loop q2)+>   loop (Enclose f2)       = enclose (fmap loop f2)+>   loop (Deliver r2)       = deliver (q1, r2)+> (Enclose f1) +>>-> p2 = enclose (fmap (+>>-> p2) f1)+> p1 +>>-> p2 = fmap (p1 ,) (decouple p2)++> -- | The @>>->+@ represents a pull-based composition of stream processors+> --   that is partial on the right (demand) side, so that @p1 >>->+ p2@+> --   represents a stream processor that forwards the output of @p1@ to @p2@,+> --   delivering the result of @p1@ and the remainder (unproduced portion)+> --   of @p2@. The new processor is /driven/ by @p1@, so, if the base functor+> --   represents a non-commutative monad, any effects of @p1@ will be observed+> --   before those of @p2@.++> (>>->+) :: Functor f => P a a' b b' f r1 -> P b' b c c' f r2 -> P a a' c c' f (r1, P b' b c c' f r2)+> (Consume x1 k1 q1) >>->+ p2 = consume x1 ((>>->+ p2) . k1) (q1 >>->+ p2)+> (Produce y1 k1 q1) >>->+ p2 = loop p2+>  where+>   loop (Consume x2 k2  _) = k1 x2 >>->+ k2 y1+>   loop (Produce y2 k2 q2) = produce y2 (loop . k2) (deplete $ loop q2)+>   loop (Enclose f2)       = enclose (fmap loop f2)+>   loop p2'                = fmap (, p2') q1+> (Enclose f1) >>->+ p2 = enclose (fmap (>>->+ p2) f1)+> (Deliver r1) >>->+ p2 = deliver (r1, p2)++> -- | The @>->>@ represents a pull-based composition of stream processors. > --   @p1 >->> p2@ represents a stream processor that forwards the output > --   of @p1@ to @p2@, delivering the result of both processors.-> --   The new processor is /driven/ by @p1@, so, if the base functor-> --   represents a non-commutative monad, any effects of @p1@ will be-> --   observed before those of @p2@.+> --   The new processor is /driven/ by @p2@, so, if the base functor+> --   represents a non-commutative monad, any effects of @p2@ will be+> --   observed before those of @p1@.  > (>->>) :: Functor f => P a a' b b' f r1 -> P b' b c c' f r2 -> P a a' c c' f (r1, r2) > p1 >->> (Consume x2 k2 q2) = loop p1 >  where->   loop  (Consume x1 k1 q1) = consume x1 (loop . k1) (loop' q1)->   loop  (Produce y1 k1  _) = k1 x2 >->> k2 y1->   loop  (Enclose f1)       = enclose (fmap loop f1)->   loop  (Deliver r1)       = fmap (r1 ,) q2->   loop' (Consume  _  _ q1) = loop' q1->   loop' (Produce y1 k1  _) = k1 x2 >->> k2 y1->   loop' (Enclose f1)       = enclose (fmap loop' f1)->   loop' (Deliver r1)       = fmap (r1 ,) q2+>   loop (Consume x1 k1 q1) = consume x1 (loop . k1) (decouple $ loop q1)+>   loop (Produce y1 k1  _) = k1 x2 >->> k2 y1+>   loop (Enclose f1)       = enclose (fmap loop f1)+>   loop (Deliver r1)       = fmap (r1 ,) q2 > p1 >->> (Produce y2 k2 q2) = produce y2 ((p1 >->>) . k2) (p1 >->> q2) > p1 >->> (Enclose f2)       = enclose (fmap (p1 >->>) f2) > p1 >->> (Deliver r2)       = fmap (, r2) (deplete p1)++> -- | The @+>->>@ represents a pull-based composition of stream processors.+> --   that is partial on the left (supply) side, so that @p1 +>->> p2@+> --   represents a stream processor that forwards the output of @p1@ to @p2@,+> --   delivering the result of @p2@ and the remainder (unconsumed portion)+> --   of @p1@. The new processor is /driven/ by @p2@, so, if the base functor+> --   represents a non-commutative monad, any effects of @p2@ will be observed+> --   before those of @p1@.++> (+>->>) :: Functor f => P a a' b b' f r1 -> P b' b c c' f r2 -> P a a' c c' f (P a a' b b' f r1, r2)+> p1 +>->> (Consume x2 k2 q2) = loop p1+>  where+>   loop (Consume x1 k1 q1) = consume x1 (loop . k1) (decouple $ loop q1)+>   loop (Produce y1 k1  _) = k1 x2 +>->> k2 y1+>   loop (Enclose f1)       = enclose (fmap loop f1)+>   loop p1'                = fmap (p1' ,) q2+> p1 +>->> (Produce y2 k2 q2) = produce y2 ((p1 +>->>) . k2) (p1 +>->> q2)+> p1 +>->> (Enclose f2)       = enclose (fmap (p1 +>->>) f2)+> p1 +>->> (Deliver r2)       = deliver (p1, r2)++> -- | The @>>->+@ represents a pull-based composition of stream processors+> --   that is partial on the right (demand) side, so that @p1 >->>+ p2@+> --   represents a stream processor that forwards the output of @p1@ to @p2@,+> --   delivering the result of @p1@ and the remainder (unproduced portion)+> --   of @p2@. The new processor is /driven/ by @p2@, so, if the base functor+> --   represents a non-commutative monad, any effects of @p2@ will be observed+> --   before those of @p1@.++> (>->>+) :: Functor f => P a a' b b' f r1 -> P b' b c c' f r2 -> P a a' c c' f (r1, P b' b c c' f r2)+> p1 >->>+ (Consume x2 k2 q2) = loop p1+>  where+>   loop (Consume x1 k1 q1) = consume x1 (loop . k1) (decouple $ loop q1)+>   loop (Produce y1 k1  _) = k1 x2 >->>+ k2 y1+>   loop (Enclose f1)       = enclose (fmap loop f1)+>   loop (Deliver r1)       = deliver (r1, q2)+> p1 >->>+ (Produce y2 k2 q2) = produce y2 ((p1 >->>+) . k2) (deplete $ p1 >->>+ q2)+> p1 >->>+ (Enclose f2)       = enclose (fmap (p1 >->>+) f2)+> p1 >->>+ p2                 = fmap (, p2) (deplete p1)  > -- | An infix version of @flip fmap@ with the same precedence and associativity > --   as the stream processor composition operators '>->>' and '>>->', indended
src/Control/Quiver/Internal.lhs view
@@ -94,7 +94,7 @@ >   --   (i.e., delivered its ultimate result, hence reaching the end >   --   of processing), to the /depleted continuation/ @q@. ->   Produce b  (b' -> P a a' b b' f r) (Consumer a a' f r) |+>   Produce b (b' -> P a a' b b' f r) (Consumer a a' f r) |  >   -- | @Enclose@ allows for selective application of the base >   --   functor @f@ the the remainder of the computation.