module Data.MonadicStreamFunction.Async where
import Data.MonadicStreamFunction.InternalCore (MSF(MSF, unMSF))
import Data.MonadicStreamFunction.Util (MStream)
concatS :: Monad m => MStream m [b] -> MStream m b
concatS :: MStream m [b] -> MStream m b
concatS MStream m [b]
msf = (() -> m (b, MStream m b)) -> MStream m b
forall (m :: * -> *) a b. (a -> m (b, MSF m a b)) -> MSF m a b
MSF ((() -> m (b, MStream m b)) -> MStream m b)
-> (() -> m (b, MStream m b)) -> MStream m b
forall a b. (a -> b) -> a -> b
$ \()
_ -> MStream m [b] -> [b] -> m (b, MStream m b)
forall (m :: * -> *) a a.
Monad m =>
MSF m () [a] -> [a] -> m (a, MSF m a a)
tick MStream m [b]
msf []
where
tick :: MSF m () [a] -> [a] -> m (a, MSF m a a)
tick MSF m () [a]
msf' (a
b:[a]
bs) = (a, MSF m a a) -> m (a, MSF m a a)
forall (m :: * -> *) a. Monad m => a -> m a
return (a
b, (a -> m (a, MSF m a a)) -> MSF m a a
forall (m :: * -> *) a b. (a -> m (b, MSF m a b)) -> MSF m a b
MSF ((a -> m (a, MSF m a a)) -> MSF m a a)
-> (a -> m (a, MSF m a a)) -> MSF m a a
forall a b. (a -> b) -> a -> b
$ \a
_ -> MSF m () [a] -> [a] -> m (a, MSF m a a)
tick MSF m () [a]
msf' [a]
bs)
tick MSF m () [a]
msf' [] = do
([a]
bs, MSF m () [a]
msf'') <- MSF m () [a] -> () -> m ([a], MSF m () [a])
forall (m :: * -> *) a b. MSF m a b -> a -> m (b, MSF m a b)
unMSF MSF m () [a]
msf' ()
MSF m () [a] -> [a] -> m (a, MSF m a a)
tick MSF m () [a]
msf'' [a]
bs