12345678910111213141516171819202122232425262728 |
- {-# LANGUAGE TypeFamilies #-}
- module Control.Monad.Trans.Interruptible where
- import Control.Monad.Trans.Interruptible.Class
- {- |
- Folds the second list with the function applied to the first,
- intercalating the evaluation. That is:
- @
- intercalateM f [a00, a10, a20] [b1, b2] = do
- a01 <- f a00 b1
- a11 <- f a10 b1
- a21 <- f a20 b1
- a02 <- f a11 b2
- a12 <- f a21 b2
- a22 <- f a31 b2
- return [a02, a12, a22]
- @
- Usefull for consuming lazy sequences.
- -}
- intercalateM :: (InterruptibleMonadTrans m, Monad n) => (b -> a -> m n a) -> [b] -> [RDt m a] -> n [RDt m a]
- intercalateM _ [] aa = return aa
- intercalateM f (b:bb) aa = do
- aa' <- mapM (\x -> runT x $ f b) aa
- intercalateM f bb aa'
|