module Streamly.Internal.Data.Cont
( contListMap
)
where
import Control.Monad.Cont (runCont, cont)
contListMap ::
(a -> (b -> r) -> r)
-> ([b] -> (c -> r) -> r)
-> ([a] -> (c -> r) -> r)
contListMap :: forall a b r c.
(a -> (b -> r) -> r)
-> ([b] -> (c -> r) -> r) -> [a] -> (c -> r) -> r
contListMap a -> (b -> r) -> r
f [b] -> (c -> r) -> r
g [a]
xs c -> r
final =
let bconts :: [Cont r b]
bconts = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a r. ((a -> r) -> r) -> Cont r a
cont forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> (b -> r) -> r
f) [a]
xs
blistCont :: ContT r Identity [b]
blistCont = forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [Cont r b]
bconts
k :: [b] -> r
k [b]
ys = [b] -> (c -> r) -> r
g [b]
ys c -> r
final
in forall r a. Cont r a -> (a -> r) -> r
runCont ContT r Identity [b]
blistCont [b] -> r
k