{-# OPTIONS_GHC -Wno-name-shadowing #-}
{-# OPTIONS_HADDOCK hide #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE LinearTypes #-}
{-# LANGUAGE QualifiedDo #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Streaming.Internal.Many
(
unzip
, ZipResidual
, ZipResidual3
, zip
, zipR
, zipWith
, zipWithR
, zip3
, zip3R
, zipWith3
, zipWith3R
, Either3 (..)
, merge
, mergeOn
, mergeBy
) where
import Streaming.Internal.Type
import Streaming.Internal.Consume
import Prelude (Either(..), Ord(..), Ordering(..))
import Prelude.Linear (($), (&))
import qualified Control.Functor.Linear as Control
unzip :: Control.Monad m =>
Stream (Of (a, b)) m r %1-> Stream (Of a) (Stream (Of b) m) r
unzip :: forall (m :: * -> *) a b r.
Monad m =>
Stream (Of (a, b)) m r %1 -> Stream (Of a) (Stream (Of b) m) r
unzip = Stream (Of (a, b)) m r %1 -> Stream (Of a) (Stream (Of b) m) r
forall (m :: * -> *) a b r.
Monad m =>
Stream (Of (a, b)) m r %1 -> Stream (Of a) (Stream (Of b) m) r
loop
where
loop :: Control.Monad m =>
Stream (Of (a, b)) m r %1-> Stream (Of a) (Stream (Of b) m) r
loop :: forall (m :: * -> *) a b r.
Monad m =>
Stream (Of (a, b)) m r %1 -> Stream (Of a) (Stream (Of b) m) r
loop Stream (Of (a, b)) m r
stream = Stream (Of (a, b)) m r
stream Stream (Of (a, b)) m r
%1 -> (Stream (Of (a, b)) m r
%1 -> Stream (Of a) (Stream (Of b) m) r)
%1 -> Stream (Of a) (Stream (Of b) m) r
forall a b. a %1 -> (a %1 -> b) %1 -> b
& \case
Return r
r -> r %1 -> Stream (Of a) (Stream (Of b) m) r
forall r (f :: * -> *) (m :: * -> *). r -> Stream f m r
Return r
r
Effect m (Stream (Of (a, b)) m r)
m -> Stream (Of b) m (Stream (Of a) (Stream (Of b) m) r)
%1 -> Stream (Of a) (Stream (Of b) m) r
forall (m :: * -> *) (f :: * -> *) r.
m (Stream f m r) -> Stream f m r
Effect (Stream (Of b) m (Stream (Of a) (Stream (Of b) m) r)
%1 -> Stream (Of a) (Stream (Of b) m) r)
%1 -> Stream (Of b) m (Stream (Of a) (Stream (Of b) m) r)
%1 -> Stream (Of a) (Stream (Of b) m) r
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ (Stream (Of (a, b)) m r %1 -> Stream (Of a) (Stream (Of b) m) r)
%1 -> Stream (Of b) m (Stream (Of (a, b)) m r)
%1 -> Stream (Of b) m (Stream (Of a) (Stream (Of b) m) r)
forall (f :: * -> *) a b.
Functor f =>
(a %1 -> b) %1 -> f a %1 -> f b
Control.fmap Stream (Of (a, b)) m r %1 -> Stream (Of a) (Stream (Of b) m) r
forall (m :: * -> *) a b r.
Monad m =>
Stream (Of (a, b)) m r %1 -> Stream (Of a) (Stream (Of b) m) r
loop (Stream (Of b) m (Stream (Of (a, b)) m r)
%1 -> Stream (Of b) m (Stream (Of a) (Stream (Of b) m) r))
%1 -> Stream (Of b) m (Stream (Of (a, b)) m r)
%1 -> Stream (Of b) m (Stream (Of a) (Stream (Of b) m) r)
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ m (Stream (Of (a, b)) m r)
%1 -> Stream (Of b) m (Stream (Of (a, b)) m r)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a %1 -> t m a
Control.lift m (Stream (Of (a, b)) m r)
m
Step ((a
a,b
b):> Stream (Of (a, b)) m r
rest) -> Of a (Stream (Of a) (Stream (Of b) m) r)
%1 -> Stream (Of a) (Stream (Of b) m) r
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (a
a a
-> Stream (Of a) (Stream (Of b) m) r
%1 -> Of a (Stream (Of a) (Stream (Of b) m) r)
forall a b. a -> b -> Of a b
:> Stream (Of b) m (Stream (Of a) (Stream (Of b) m) r)
%1 -> Stream (Of a) (Stream (Of b) m) r
forall (m :: * -> *) (f :: * -> *) r.
m (Stream f m r) -> Stream f m r
Effect (Of b (Stream (Of b) m (Stream (Of a) (Stream (Of b) m) r))
%1 -> Stream (Of b) m (Stream (Of a) (Stream (Of b) m) r)
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (b
b b
-> Stream (Of b) m (Stream (Of a) (Stream (Of b) m) r)
%1 -> Of b (Stream (Of b) m (Stream (Of a) (Stream (Of b) m) r))
forall a b. a -> b -> Of a b
:> Stream (Of a) (Stream (Of b) m) r
%1 -> Stream (Of b) m (Stream (Of a) (Stream (Of b) m) r)
forall r (f :: * -> *) (m :: * -> *). r -> Stream f m r
Return (Stream (Of (a, b)) m r %1 -> Stream (Of a) (Stream (Of b) m) r
forall (m :: * -> *) a b r.
Monad m =>
Stream (Of (a, b)) m r %1 -> Stream (Of a) (Stream (Of b) m) r
loop Stream (Of (a, b)) m r
rest))))
{-# INLINABLE unzip #-}
data Either3 a b c where
Left3 :: a %1-> Either3 a b c
Middle3 :: b %1-> Either3 a b c
Right3 :: c %1-> Either3 a b c
type ZipResidual a b m r1 r2 =
Either3
(r1, r2)
(r1, Stream (Of b) m r2)
(Stream (Of a) m r1, r2)
zipWithR :: Control.Monad m =>
(a -> b -> c) ->
Stream (Of a) m r1 %1->
Stream (Of b) m r2 %1->
Stream (Of c) m (ZipResidual a b m r1 r2)
zipWithR :: forall (m :: * -> *) a b c r1 r2.
Monad m =>
(a -> b -> c)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
zipWithR = (a -> b -> c)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall (m :: * -> *) a b c r1 r2.
Monad m =>
(a -> b -> c)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
loop
where
loop :: Control.Monad m =>
(a -> b -> c) ->
Stream (Of a) m r1 %1->
Stream (Of b) m r2 %1->
Stream (Of c) m (ZipResidual a b m r1 r2)
loop :: forall (m :: * -> *) a b c r1 r2.
Monad m =>
(a -> b -> c)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
loop a -> b -> c
f Stream (Of a) m r1
st1 Stream (Of b) m r2
st2 = Stream (Of a) m r1
st1 Stream (Of a) m r1
%1 -> (Stream (Of a) m r1
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall a b. a %1 -> (a %1 -> b) %1 -> b
& \case
Effect m (Stream (Of a) m r1)
ms -> m (Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall (m :: * -> *) (f :: * -> *) r.
m (Stream f m r) -> Stream f m r
Effect (m (Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> m (Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ (Stream (Of a) m r1
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> m (Stream (Of a) m r1)
%1 -> m (Stream (Of c) m (ZipResidual a b m r1 r2))
forall (f :: * -> *) a b.
Functor f =>
(a %1 -> b) %1 -> f a %1 -> f b
Control.fmap (\Stream (Of a) m r1
s -> (a -> b -> c)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall (m :: * -> *) a b c r1 r2.
Monad m =>
(a -> b -> c)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
loop a -> b -> c
f Stream (Of a) m r1
s Stream (Of b) m r2
st2) m (Stream (Of a) m r1)
ms
Return r1
r1 -> Stream (Of b) m r2
st2 Stream (Of b) m r2
%1 -> (Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall a b. a %1 -> (a %1 -> b) %1 -> b
& \case
Return r2
r2 -> ZipResidual a b m r1 r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall r (f :: * -> *) (m :: * -> *). r -> Stream f m r
Return (ZipResidual a b m r1 r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> ZipResidual a b m r1 r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ (r1, r2) %1 -> ZipResidual a b m r1 r2
forall a b c. a -> Either3 a b c
Left3 (r1
r1,r2
r2)
Stream (Of b) m r2
st2' -> ZipResidual a b m r1 r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall r (f :: * -> *) (m :: * -> *). r -> Stream f m r
Return (ZipResidual a b m r1 r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> ZipResidual a b m r1 r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ (r1, Stream (Of b) m r2) %1 -> ZipResidual a b m r1 r2
forall b a c. b -> Either3 a b c
Middle3 (r1
r1,Stream (Of b) m r2
st2')
Step (a
a :> Stream (Of a) m r1
as) -> Stream (Of b) m r2
st2 Stream (Of b) m r2
%1 -> (Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall a b. a %1 -> (a %1 -> b) %1 -> b
& \case
Effect m (Stream (Of b) m r2)
ms ->
m (Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall (m :: * -> *) (f :: * -> *) r.
m (Stream f m r) -> Stream f m r
Effect (m (Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> m (Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ (Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> m (Stream (Of b) m r2)
%1 -> m (Stream (Of c) m (ZipResidual a b m r1 r2))
forall (f :: * -> *) a b.
Functor f =>
(a %1 -> b) %1 -> f a %1 -> f b
Control.fmap (\Stream (Of b) m r2
s -> (a -> b -> c)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall (m :: * -> *) a b c r1 r2.
Monad m =>
(a -> b -> c)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
loop a -> b -> c
f (Of a (Stream (Of a) m r1) %1 -> Stream (Of a) m r1
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (a
a a -> Stream (Of a) m r1 %1 -> Of a (Stream (Of a) m r1)
forall a b. a -> b -> Of a b
:> Stream (Of a) m r1
as)) Stream (Of b) m r2
s) m (Stream (Of b) m r2)
ms
Return r2
r2 -> ZipResidual a b m r1 r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall r (f :: * -> *) (m :: * -> *). r -> Stream f m r
Return (ZipResidual a b m r1 r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> ZipResidual a b m r1 r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ (Stream (Of a) m r1, r2) %1 -> ZipResidual a b m r1 r2
forall c a b. c -> Either3 a b c
Right3 (Of a (Stream (Of a) m r1) %1 -> Stream (Of a) m r1
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (a
a a -> Stream (Of a) m r1 %1 -> Of a (Stream (Of a) m r1)
forall a b. a -> b -> Of a b
:> Stream (Of a) m r1
as), r2
r2)
Step (b
b :> Stream (Of b) m r2
bs) -> Of c (Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (Of c (Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> Of c (Stream (Of c) m (ZipResidual a b m r1 r2))
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ (a -> b -> c
f a
a b
b) c
-> Stream (Of c) m (ZipResidual a b m r1 r2)
%1 -> Of c (Stream (Of c) m (ZipResidual a b m r1 r2))
forall a b. a -> b -> Of a b
:> (a -> b -> c)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall (m :: * -> *) a b c r1 r2.
Monad m =>
(a -> b -> c)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
loop a -> b -> c
f Stream (Of a) m r1
as Stream (Of b) m r2
bs
{-# INLINABLE zipWithR #-}
zipWith :: Control.Monad m =>
(a -> b -> c) ->
Stream (Of a) m r1 %1->
Stream (Of b) m r2 %1->
Stream (Of c) m (r1,r2)
zipWith :: forall (m :: * -> *) a b c r1 r2.
Monad m =>
(a -> b -> c)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m (r1, r2)
zipWith a -> b -> c
f Stream (Of a) m r1
s1 Stream (Of b) m r2
s2 = Control.do
ZipResidual a b m r1 r2
result <- (a -> b -> c)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
forall (m :: * -> *) a b c r1 r2.
Monad m =>
(a -> b -> c)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
zipWithR a -> b -> c
f Stream (Of a) m r1
s1 Stream (Of b) m r2
s2
ZipResidual a b m r1 r2
result ZipResidual a b m r1 r2
%1 -> (ZipResidual a b m r1 r2 %1 -> Stream (Of c) m (r1, r2))
%1 -> Stream (Of c) m (r1, r2)
forall a b. a %1 -> (a %1 -> b) %1 -> b
& \case
Left3 (r1, r2)
rets -> (r1, r2) %1 -> Stream (Of c) m (r1, r2)
forall (m :: * -> *) a. Monad m => a %1 -> m a
Control.return (r1, r2)
rets
Middle3 (r1
r1, Stream (Of b) m r2
s2') -> Control.do
r2
r2 <- m r2 %1 -> Stream (Of c) m r2
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a %1 -> t m a
Control.lift (m r2 %1 -> Stream (Of c) m r2) %1 -> m r2 %1 -> Stream (Of c) m r2
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ Stream (Of b) m r2 %1 -> m r2
forall a (m :: * -> *) r. Monad m => Stream (Of a) m r %1 -> m r
effects Stream (Of b) m r2
s2'
(r1, r2) %1 -> Stream (Of c) m (r1, r2)
forall (m :: * -> *) a. Monad m => a %1 -> m a
Control.return (r1
r1, r2
r2)
Right3 (Stream (Of a) m r1
s1', r2
r2) -> Control.do
r1
r1 <- m r1 %1 -> Stream (Of c) m r1
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a %1 -> t m a
Control.lift (m r1 %1 -> Stream (Of c) m r1) %1 -> m r1 %1 -> Stream (Of c) m r1
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ Stream (Of a) m r1 %1 -> m r1
forall a (m :: * -> *) r. Monad m => Stream (Of a) m r %1 -> m r
effects Stream (Of a) m r1
s1'
(r1, r2) %1 -> Stream (Of c) m (r1, r2)
forall (m :: * -> *) a. Monad m => a %1 -> m a
Control.return (r1
r1, r2
r2)
{-# INLINABLE zipWith #-}
zip :: Control.Monad m =>
Stream (Of a) m r1 %1->
Stream (Of b) m r2 %1->
Stream (Of (a,b)) m (r1, r2)
zip :: forall (m :: * -> *) a r1 b r2.
Monad m =>
Stream (Of a) m r1
%1 -> Stream (Of b) m r2 %1 -> Stream (Of (a, b)) m (r1, r2)
zip = (a -> b -> (a, b))
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of (a, b)) m (r1, r2)
forall (m :: * -> *) a b c r1 r2.
Monad m =>
(a -> b -> c)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m (r1, r2)
zipWith (,)
{-# INLINE zip #-}
zipR :: Control.Monad m =>
Stream (Of a) m r1 %1->
Stream (Of b) m r2 %1->
Stream (Of (a,b)) m (ZipResidual a b m r1 r2)
zipR :: forall (m :: * -> *) a r1 b r2.
Monad m =>
Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of (a, b)) m (ZipResidual a b m r1 r2)
zipR = (a -> b -> (a, b))
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of (a, b)) m (ZipResidual a b m r1 r2)
forall (m :: * -> *) a b c r1 r2.
Monad m =>
(a -> b -> c)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m (ZipResidual a b m r1 r2)
zipWithR (,)
{-# INLINE zipR #-}
type ZipResidual3 a b c m r1 r2 r3 =
( Either r1 (Stream (Of a) m r1)
, Either r2 (Stream (Of b) m r2)
, Either r3 (Stream (Of c) m r3)
)
zipWith3R :: Control.Monad m =>
(a -> b -> c -> d) ->
Stream (Of a) m r1 %1->
Stream (Of b) m r2 %1->
Stream (Of c) m r3 %1->
Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
zipWith3R :: forall (m :: * -> *) a b c d r1 r2 r3.
Monad m =>
(a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
zipWith3R = (a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall (m :: * -> *) a b c d r1 r2 r3.
Monad m =>
(a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
loop
where
loop :: Control.Monad m =>
(a -> b -> c -> d) ->
Stream (Of a) m r1 %1->
Stream (Of b) m r2 %1->
Stream (Of c) m r3 %1->
Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
loop :: forall (m :: * -> *) a b c d r1 r2 r3.
Monad m =>
(a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
loop a -> b -> c -> d
f Stream (Of a) m r1
s1 Stream (Of b) m r2
s2 Stream (Of c) m r3
s3 = Stream (Of a) m r1
s1 Stream (Of a) m r1
%1 -> (Stream (Of a) m r1
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall a b. a %1 -> (a %1 -> b) %1 -> b
& \case
Effect m (Stream (Of a) m r1)
ms -> m (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall (m :: * -> *) (f :: * -> *) r.
m (Stream f m r) -> Stream f m r
Effect (m (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> m (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ (Stream (Of a) m r1
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> m (Stream (Of a) m r1)
%1 -> m (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
forall (f :: * -> *) a b.
Functor f =>
(a %1 -> b) %1 -> f a %1 -> f b
Control.fmap (\Stream (Of a) m r1
s -> (a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall (m :: * -> *) a b c d r1 r2 r3.
Monad m =>
(a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
loop a -> b -> c -> d
f Stream (Of a) m r1
s Stream (Of b) m r2
s2 Stream (Of c) m r3
s3) m (Stream (Of a) m r1)
ms
Return r1
r1 -> (Stream (Of b) m r2
s2, Stream (Of c) m r3
s3) (Stream (Of b) m r2, Stream (Of c) m r3)
%1 -> ((Stream (Of b) m r2, Stream (Of c) m r3)
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall a b. a %1 -> (a %1 -> b) %1 -> b
& \case
(Return r2
r2, Return r3
r3) -> ZipResidual3 a b c m r1 r2 r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall r (f :: * -> *) (m :: * -> *). r -> Stream f m r
Return (r1 %1 -> Either r1 (Stream (Of a) m r1)
forall a b. a -> Either a b
Left r1
r1, r2 %1 -> Either r2 (Stream (Of b) m r2)
forall a b. a -> Either a b
Left r2
r2, r3 %1 -> Either r3 (Stream (Of c) m r3)
forall a b. a -> Either a b
Left r3
r3)
(Stream (Of b) m r2
s2', Stream (Of c) m r3
s3') -> ZipResidual3 a b c m r1 r2 r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall r (f :: * -> *) (m :: * -> *). r -> Stream f m r
Return (r1 %1 -> Either r1 (Stream (Of a) m r1)
forall a b. a -> Either a b
Left r1
r1, Stream (Of b) m r2 %1 -> Either r2 (Stream (Of b) m r2)
forall a b. b -> Either a b
Right Stream (Of b) m r2
s2', Stream (Of c) m r3 %1 -> Either r3 (Stream (Of c) m r3)
forall a b. b -> Either a b
Right Stream (Of c) m r3
s3')
Step (a
a :> Stream (Of a) m r1
as) -> Stream (Of b) m r2
s2 Stream (Of b) m r2
%1 -> (Stream (Of b) m r2
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall a b. a %1 -> (a %1 -> b) %1 -> b
& \case
Effect m (Stream (Of b) m r2)
ms -> m (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall (m :: * -> *) (f :: * -> *) r.
m (Stream f m r) -> Stream f m r
Effect (m (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> m (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall a b. (a %1 -> b) %1 -> a %1 -> b
$
(Stream (Of b) m r2
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> m (Stream (Of b) m r2)
%1 -> m (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
forall (f :: * -> *) a b.
Functor f =>
(a %1 -> b) %1 -> f a %1 -> f b
Control.fmap (\Stream (Of b) m r2
s -> (a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall (m :: * -> *) a b c d r1 r2 r3.
Monad m =>
(a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
loop a -> b -> c -> d
f (Of a (Stream (Of a) m r1) %1 -> Stream (Of a) m r1
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (Of a (Stream (Of a) m r1) %1 -> Stream (Of a) m r1)
%1 -> Of a (Stream (Of a) m r1) %1 -> Stream (Of a) m r1
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ a
a a -> Stream (Of a) m r1 %1 -> Of a (Stream (Of a) m r1)
forall a b. a -> b -> Of a b
:> Stream (Of a) m r1
as) Stream (Of b) m r2
s Stream (Of c) m r3
s3) m (Stream (Of b) m r2)
ms
Return r2
r2 -> ZipResidual3 a b c m r1 r2 r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall r (f :: * -> *) (m :: * -> *). r -> Stream f m r
Return (Stream (Of a) m r1 %1 -> Either r1 (Stream (Of a) m r1)
forall a b. b -> Either a b
Right (Of a (Stream (Of a) m r1) %1 -> Stream (Of a) m r1
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (Of a (Stream (Of a) m r1) %1 -> Stream (Of a) m r1)
%1 -> Of a (Stream (Of a) m r1) %1 -> Stream (Of a) m r1
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ a
a a -> Stream (Of a) m r1 %1 -> Of a (Stream (Of a) m r1)
forall a b. a -> b -> Of a b
:> Stream (Of a) m r1
as), r2 %1 -> Either r2 (Stream (Of b) m r2)
forall a b. a -> Either a b
Left r2
r2, Stream (Of c) m r3 %1 -> Either r3 (Stream (Of c) m r3)
forall a b. b -> Either a b
Right Stream (Of c) m r3
s3)
Step (b
b :> Stream (Of b) m r2
bs) -> Stream (Of c) m r3
s3 Stream (Of c) m r3
%1 -> (Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall a b. a %1 -> (a %1 -> b) %1 -> b
& \case
Effect m (Stream (Of c) m r3)
ms -> m (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall (m :: * -> *) (f :: * -> *) r.
m (Stream f m r) -> Stream f m r
Effect (m (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> m (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall a b. (a %1 -> b) %1 -> a %1 -> b
$
(Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> m (Stream (Of c) m r3)
%1 -> m (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
forall (f :: * -> *) a b.
Functor f =>
(a %1 -> b) %1 -> f a %1 -> f b
Control.fmap (\Stream (Of c) m r3
s -> (a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall (m :: * -> *) a b c d r1 r2 r3.
Monad m =>
(a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
loop a -> b -> c -> d
f (Of a (Stream (Of a) m r1) %1 -> Stream (Of a) m r1
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (Of a (Stream (Of a) m r1) %1 -> Stream (Of a) m r1)
%1 -> Of a (Stream (Of a) m r1) %1 -> Stream (Of a) m r1
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ a
a a -> Stream (Of a) m r1 %1 -> Of a (Stream (Of a) m r1)
forall a b. a -> b -> Of a b
:> Stream (Of a) m r1
as) (Of b (Stream (Of b) m r2) %1 -> Stream (Of b) m r2
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (Of b (Stream (Of b) m r2) %1 -> Stream (Of b) m r2)
%1 -> Of b (Stream (Of b) m r2) %1 -> Stream (Of b) m r2
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ b
b b -> Stream (Of b) m r2 %1 -> Of b (Stream (Of b) m r2)
forall a b. a -> b -> Of a b
:> Stream (Of b) m r2
bs) Stream (Of c) m r3
s) m (Stream (Of c) m r3)
ms
Return r3
r3 ->
ZipResidual3 a b c m r1 r2 r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall r (f :: * -> *) (m :: * -> *). r -> Stream f m r
Return (Stream (Of a) m r1 %1 -> Either r1 (Stream (Of a) m r1)
forall a b. b -> Either a b
Right (Of a (Stream (Of a) m r1) %1 -> Stream (Of a) m r1
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (Of a (Stream (Of a) m r1) %1 -> Stream (Of a) m r1)
%1 -> Of a (Stream (Of a) m r1) %1 -> Stream (Of a) m r1
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ a
a a -> Stream (Of a) m r1 %1 -> Of a (Stream (Of a) m r1)
forall a b. a -> b -> Of a b
:> Stream (Of a) m r1
as), Stream (Of b) m r2 %1 -> Either r2 (Stream (Of b) m r2)
forall a b. b -> Either a b
Right (Of b (Stream (Of b) m r2) %1 -> Stream (Of b) m r2
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (Of b (Stream (Of b) m r2) %1 -> Stream (Of b) m r2)
%1 -> Of b (Stream (Of b) m r2) %1 -> Stream (Of b) m r2
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ b
b b -> Stream (Of b) m r2 %1 -> Of b (Stream (Of b) m r2)
forall a b. a -> b -> Of a b
:> Stream (Of b) m r2
bs), r3 %1 -> Either r3 (Stream (Of c) m r3)
forall a b. a -> Either a b
Left r3
r3)
Step (c
c :> Stream (Of c) m r3
cs) -> Of d (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (Of d (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Of d (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ (a -> b -> c -> d
f a
a b
b c
c) d
-> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
%1 -> Of d (Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3))
forall a b. a -> b -> Of a b
:> (a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall (m :: * -> *) a b c d r1 r2 r3.
Monad m =>
(a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
loop a -> b -> c -> d
f Stream (Of a) m r1
as Stream (Of b) m r2
bs Stream (Of c) m r3
cs
{-# INLINABLE zipWith3R #-}
zipWith3 :: Control.Monad m =>
(a -> b -> c -> d) ->
Stream (Of a) m r1 %1->
Stream (Of b) m r2 %1->
Stream (Of c) m r3 %1->
Stream (Of d) m (r1, r2, r3)
zipWith3 :: forall (m :: * -> *) a b c d r1 r2 r3.
Monad m =>
(a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (r1, r2, r3)
zipWith3 a -> b -> c -> d
f Stream (Of a) m r1
s1 Stream (Of b) m r2
s2 Stream (Of c) m r3
s3 = Control.do
ZipResidual3 a b c m r1 r2 r3
result <- (a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
forall (m :: * -> *) a b c d r1 r2 r3.
Monad m =>
(a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
zipWith3R a -> b -> c -> d
f Stream (Of a) m r1
s1 Stream (Of b) m r2
s2 Stream (Of c) m r3
s3
ZipResidual3 a b c m r1 r2 r3
result ZipResidual3 a b c m r1 r2 r3
%1 -> (ZipResidual3 a b c m r1 r2 r3
%1 -> Stream (Of d) m (r1, r2, r3))
%1 -> Stream (Of d) m (r1, r2, r3)
forall a b. a %1 -> (a %1 -> b) %1 -> b
& \case
(Either r1 (Stream (Of a) m r1)
res1, Either r2 (Stream (Of b) m r2)
res2, Either r3 (Stream (Of c) m r3)
res3) -> Control.do
r1
r1 <- m r1 %1 -> Stream (Of d) m r1
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a %1 -> t m a
Control.lift (m r1 %1 -> Stream (Of d) m r1) %1 -> m r1 %1 -> Stream (Of d) m r1
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ Either r1 (Stream (Of a) m r1) %1 -> m r1
forall (m :: * -> *) r a.
Monad m =>
Either r (Stream (Of a) m r) %1 -> m r
extractResult Either r1 (Stream (Of a) m r1)
res1
r2
r2 <- m r2 %1 -> Stream (Of d) m r2
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a %1 -> t m a
Control.lift (m r2 %1 -> Stream (Of d) m r2) %1 -> m r2 %1 -> Stream (Of d) m r2
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ Either r2 (Stream (Of b) m r2) %1 -> m r2
forall (m :: * -> *) r a.
Monad m =>
Either r (Stream (Of a) m r) %1 -> m r
extractResult Either r2 (Stream (Of b) m r2)
res2
r3
r3 <- m r3 %1 -> Stream (Of d) m r3
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a %1 -> t m a
Control.lift (m r3 %1 -> Stream (Of d) m r3) %1 -> m r3 %1 -> Stream (Of d) m r3
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ Either r3 (Stream (Of c) m r3) %1 -> m r3
forall (m :: * -> *) r a.
Monad m =>
Either r (Stream (Of a) m r) %1 -> m r
extractResult Either r3 (Stream (Of c) m r3)
res3
(r1, r2, r3) %1 -> Stream (Of d) m (r1, r2, r3)
forall (m :: * -> *) a. Monad m => a %1 -> m a
Control.return (r1
r1, r2
r2, r3
r3)
{-# INLINABLE zipWith3 #-}
zip3 :: Control.Monad m =>
Stream (Of a) m r1 %1->
Stream (Of b) m r2 %1->
Stream (Of c) m r3 %1->
Stream (Of (a,b,c)) m (r1, r2, r3)
zip3 :: forall (m :: * -> *) a r1 b r2 c r3.
Monad m =>
Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of (a, b, c)) m (r1, r2, r3)
zip3 = (a -> b -> c -> (a, b, c))
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of (a, b, c)) m (r1, r2, r3)
forall (m :: * -> *) a b c d r1 r2 r3.
Monad m =>
(a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (r1, r2, r3)
zipWith3 (,,)
{-# INLINABLE zip3 #-}
zip3R :: Control.Monad m =>
Stream (Of a) m r1 %1->
Stream (Of b) m r2 %1->
Stream (Of c) m r3 %1->
Stream (Of (a,b,c)) m (ZipResidual3 a b c m r1 r2 r3)
zip3R :: forall (m :: * -> *) a r1 b r2 c r3.
Monad m =>
Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of (a, b, c)) m (ZipResidual3 a b c m r1 r2 r3)
zip3R = (a -> b -> c -> (a, b, c))
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of (a, b, c)) m (ZipResidual3 a b c m r1 r2 r3)
forall (m :: * -> *) a b c d r1 r2 r3.
Monad m =>
(a -> b -> c -> d)
-> Stream (Of a) m r1
%1 -> Stream (Of b) m r2
%1 -> Stream (Of c) m r3
%1 -> Stream (Of d) m (ZipResidual3 a b c m r1 r2 r3)
zipWith3R (,,)
{-# INLINABLE zip3R #-}
extractResult :: Control.Monad m => Either r (Stream (Of a) m r) %1-> m r
(Left r
r) = r %1 -> m r
forall (m :: * -> *) a. Monad m => a %1 -> m a
Control.return r
r
extractResult (Right Stream (Of a) m r
s) = Stream (Of a) m r %1 -> m r
forall a (m :: * -> *) r. Monad m => Stream (Of a) m r %1 -> m r
effects Stream (Of a) m r
s
merge :: (Control.Monad m, Ord a) =>
Stream (Of a) m r %1-> Stream (Of a) m s %1-> Stream (Of a) m (r,s)
merge :: forall (m :: * -> *) a r s.
(Monad m, Ord a) =>
Stream (Of a) m r
%1 -> Stream (Of a) m s %1 -> Stream (Of a) m (r, s)
merge = (a -> a -> Ordering)
-> Stream (Of a) m r
%1 -> Stream (Of a) m s
%1 -> Stream (Of a) m (r, s)
forall (m :: * -> *) a r s.
Monad m =>
(a -> a -> Ordering)
-> Stream (Of a) m r
%1 -> Stream (Of a) m s
%1 -> Stream (Of a) m (r, s)
mergeBy a -> a -> Ordering
forall a. Ord a => a -> a -> Ordering
compare
{-# INLINE merge #-}
mergeOn :: (Control.Monad m, Ord b) =>
(a -> b) ->
Stream (Of a) m r %1->
Stream (Of a) m s %1->
Stream (Of a) m (r,s)
mergeOn :: forall (m :: * -> *) b a r s.
(Monad m, Ord b) =>
(a -> b)
-> Stream (Of a) m r
%1 -> Stream (Of a) m s
%1 -> Stream (Of a) m (r, s)
mergeOn a -> b
f = (a -> a -> Ordering)
-> Stream (Of a) m r
%1 -> Stream (Of a) m s
%1 -> Stream (Of a) m (r, s)
forall (m :: * -> *) a r s.
Monad m =>
(a -> a -> Ordering)
-> Stream (Of a) m r
%1 -> Stream (Of a) m s
%1 -> Stream (Of a) m (r, s)
mergeBy (\a
x a
y -> b -> b -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (a -> b
f a
x) (a -> b
f a
y))
{-# INLINE mergeOn #-}
mergeBy :: forall m a r s . Control.Monad m =>
(a -> a -> Ordering) ->
Stream (Of a) m r %1->
Stream (Of a) m s %1->
Stream (Of a) m (r,s)
mergeBy :: forall (m :: * -> *) a r s.
Monad m =>
(a -> a -> Ordering)
-> Stream (Of a) m r
%1 -> Stream (Of a) m s
%1 -> Stream (Of a) m (r, s)
mergeBy a -> a -> Ordering
comp Stream (Of a) m r
s1 Stream (Of a) m s
s2 = Stream (Of a) m r
%1 -> Stream (Of a) m s %1 -> Stream (Of a) m (r, s)
loop Stream (Of a) m r
s1 Stream (Of a) m s
s2
where
loop :: Stream (Of a) m r %1-> Stream (Of a) m s %1-> Stream (Of a) m (r,s)
loop :: Stream (Of a) m r
%1 -> Stream (Of a) m s %1 -> Stream (Of a) m (r, s)
loop Stream (Of a) m r
s1 Stream (Of a) m s
s2 = Stream (Of a) m r
s1 Stream (Of a) m r
%1 -> (Stream (Of a) m r %1 -> Stream (Of a) m (r, s))
%1 -> Stream (Of a) m (r, s)
forall a b. a %1 -> (a %1 -> b) %1 -> b
& \case
Return r
r ->
m (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s)
forall (m :: * -> *) (f :: * -> *) r.
m (Stream f m r) -> Stream f m r
Effect (m (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s))
%1 -> m (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s)
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ Stream (Of a) m s %1 -> m s
forall a (m :: * -> *) r. Monad m => Stream (Of a) m r %1 -> m r
effects Stream (Of a) m s
s2 m s
%1 -> (s %1 -> m (Stream (Of a) m (r, s)))
%1 -> m (Stream (Of a) m (r, s))
forall (m :: * -> *) a b.
Monad m =>
m a %1 -> (a %1 -> m b) %1 -> m b
Control.>>= \s
s -> Stream (Of a) m (r, s) %1 -> m (Stream (Of a) m (r, s))
forall (m :: * -> *) a. Monad m => a %1 -> m a
Control.return (Stream (Of a) m (r, s) %1 -> m (Stream (Of a) m (r, s)))
%1 -> Stream (Of a) m (r, s) %1 -> m (Stream (Of a) m (r, s))
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ (r, s) %1 -> Stream (Of a) m (r, s)
forall r (f :: * -> *) (m :: * -> *). r -> Stream f m r
Return (r
r, s
s)
Effect m (Stream (Of a) m r)
ms -> m (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s)
forall (m :: * -> *) (f :: * -> *) r.
m (Stream f m r) -> Stream f m r
Effect (m (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s))
%1 -> m (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s)
forall a b. (a %1 -> b) %1 -> a %1 -> b
$
m (Stream (Of a) m r)
ms m (Stream (Of a) m r)
%1 -> (Stream (Of a) m r %1 -> m (Stream (Of a) m (r, s)))
%1 -> m (Stream (Of a) m (r, s))
forall (m :: * -> *) a b.
Monad m =>
m a %1 -> (a %1 -> m b) %1 -> m b
Control.>>= \Stream (Of a) m r
s1' -> Stream (Of a) m (r, s) %1 -> m (Stream (Of a) m (r, s))
forall (m :: * -> *) a. Monad m => a %1 -> m a
Control.return (Stream (Of a) m (r, s) %1 -> m (Stream (Of a) m (r, s)))
%1 -> Stream (Of a) m (r, s) %1 -> m (Stream (Of a) m (r, s))
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ (a -> a -> Ordering)
-> Stream (Of a) m r
%1 -> Stream (Of a) m s
%1 -> Stream (Of a) m (r, s)
forall (m :: * -> *) a r s.
Monad m =>
(a -> a -> Ordering)
-> Stream (Of a) m r
%1 -> Stream (Of a) m s
%1 -> Stream (Of a) m (r, s)
mergeBy a -> a -> Ordering
comp Stream (Of a) m r
s1' Stream (Of a) m s
s2
Step (a
a :> Stream (Of a) m r
as) -> Stream (Of a) m s
s2 Stream (Of a) m s
%1 -> (Stream (Of a) m s %1 -> Stream (Of a) m (r, s))
%1 -> Stream (Of a) m (r, s)
forall a b. a %1 -> (a %1 -> b) %1 -> b
& \case
Return s
s ->
m (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s)
forall (m :: * -> *) (f :: * -> *) r.
m (Stream f m r) -> Stream f m r
Effect (m (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s))
%1 -> m (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s)
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ Stream (Of a) m r %1 -> m r
forall a (m :: * -> *) r. Monad m => Stream (Of a) m r %1 -> m r
effects Stream (Of a) m r
as m r
%1 -> (r %1 -> m (Stream (Of a) m (r, s)))
%1 -> m (Stream (Of a) m (r, s))
forall (m :: * -> *) a b.
Monad m =>
m a %1 -> (a %1 -> m b) %1 -> m b
Control.>>= \r
r -> Stream (Of a) m (r, s) %1 -> m (Stream (Of a) m (r, s))
forall (m :: * -> *) a. Monad m => a %1 -> m a
Control.return (Stream (Of a) m (r, s) %1 -> m (Stream (Of a) m (r, s)))
%1 -> Stream (Of a) m (r, s) %1 -> m (Stream (Of a) m (r, s))
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ (r, s) %1 -> Stream (Of a) m (r, s)
forall r (f :: * -> *) (m :: * -> *). r -> Stream f m r
Return (r
r, s
s)
Effect m (Stream (Of a) m s)
ms -> m (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s)
forall (m :: * -> *) (f :: * -> *) r.
m (Stream f m r) -> Stream f m r
Effect (m (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s))
%1 -> m (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s)
forall a b. (a %1 -> b) %1 -> a %1 -> b
$
m (Stream (Of a) m s)
ms m (Stream (Of a) m s)
%1 -> (Stream (Of a) m s %1 -> m (Stream (Of a) m (r, s)))
%1 -> m (Stream (Of a) m (r, s))
forall (m :: * -> *) a b.
Monad m =>
m a %1 -> (a %1 -> m b) %1 -> m b
Control.>>= \Stream (Of a) m s
s2' ->
Stream (Of a) m (r, s) %1 -> m (Stream (Of a) m (r, s))
forall (m :: * -> *) a. Monad m => a %1 -> m a
Control.return (Stream (Of a) m (r, s) %1 -> m (Stream (Of a) m (r, s)))
%1 -> Stream (Of a) m (r, s) %1 -> m (Stream (Of a) m (r, s))
forall a b. (a %1 -> b) %1 -> a %1 -> b
$ (a -> a -> Ordering)
-> Stream (Of a) m r
%1 -> Stream (Of a) m s
%1 -> Stream (Of a) m (r, s)
forall (m :: * -> *) a r s.
Monad m =>
(a -> a -> Ordering)
-> Stream (Of a) m r
%1 -> Stream (Of a) m s
%1 -> Stream (Of a) m (r, s)
mergeBy a -> a -> Ordering
comp (Of a (Stream (Of a) m r) %1 -> Stream (Of a) m r
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (a
a a -> Stream (Of a) m r %1 -> Of a (Stream (Of a) m r)
forall a b. a -> b -> Of a b
:> Stream (Of a) m r
as)) Stream (Of a) m s
s2'
Step (a
b :> Stream (Of a) m s
bs) -> case a -> a -> Ordering
comp a
a a
b of
Ordering
LT -> Of a (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s)
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (a
a a -> Stream (Of a) m (r, s) %1 -> Of a (Stream (Of a) m (r, s))
forall a b. a -> b -> Of a b
:> Of a (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s)
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (a
b a -> Stream (Of a) m (r, s) %1 -> Of a (Stream (Of a) m (r, s))
forall a b. a -> b -> Of a b
:> (a -> a -> Ordering)
-> Stream (Of a) m r
%1 -> Stream (Of a) m s
%1 -> Stream (Of a) m (r, s)
forall (m :: * -> *) a r s.
Monad m =>
(a -> a -> Ordering)
-> Stream (Of a) m r
%1 -> Stream (Of a) m s
%1 -> Stream (Of a) m (r, s)
mergeBy a -> a -> Ordering
comp Stream (Of a) m r
as Stream (Of a) m s
bs))
Ordering
_ -> Of a (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s)
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (a
b a -> Stream (Of a) m (r, s) %1 -> Of a (Stream (Of a) m (r, s))
forall a b. a -> b -> Of a b
:> Of a (Stream (Of a) m (r, s)) %1 -> Stream (Of a) m (r, s)
forall (f :: * -> *) (m :: * -> *) r.
f (Stream f m r) -> Stream f m r
Step (a
a a -> Stream (Of a) m (r, s) %1 -> Of a (Stream (Of a) m (r, s))
forall a b. a -> b -> Of a b
:> (a -> a -> Ordering)
-> Stream (Of a) m r
%1 -> Stream (Of a) m s
%1 -> Stream (Of a) m (r, s)
forall (m :: * -> *) a r s.
Monad m =>
(a -> a -> Ordering)
-> Stream (Of a) m r
%1 -> Stream (Of a) m s
%1 -> Stream (Of a) m (r, s)
mergeBy a -> a -> Ordering
comp Stream (Of a) m r
as Stream (Of a) m s
bs))
{-# INLINABLE mergeBy #-}