Hoogle Search
Within LTS Haskell 24.38 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
mapAccumR :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)ghc-internal GHC.Internal.Data.Traversable The mapAccumR function behaves like a combination of fmap and foldr; it applies a function to each element of a structure, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new structure.
Examples
Basic usage:>>> mapAccumR (\a b -> (a + b, a)) 0 [1..10] (55,[54,52,49,45,40,34,27,19,10,0])
>>> mapAccumR (\a b -> (a <> show b, a)) "0" [1..5] ("054321",["05432","0543","054","05","0"])mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)ghc-internal GHC.Internal.Data.Traversable Map each element of a structure to a monadic action, evaluate these actions from left to right, and collect the results. For a version that ignores the results see mapM_.
Examples
mapM is literally a traverse with a type signature restricted to Monad. Its implementation may be more efficient due to additional power of Monad.mapExceptionContext :: (ExceptionContext -> ExceptionContext) -> SomeException -> SomeExceptionghc-internal GHC.Internal.Exception.Type No documentation available.
mapAccumL :: (acc -> x -> (acc, y)) -> acc -> Infinite x -> Infinite yinfinite-list Data.List.Infinite Fold an infinite list from the left and return a list of successive reductions, keeping accumulator in a state:
mapAccumL f acc0 (x1 :< x2 :< ...) = let (acc1, y1) = f acc0 x1 in let (acc2, y2) = f acc1 x2 in ... y1 :< y2 :< ...
If you are looking how to traverse with a state, look no further.mapAccumL' :: (acc -> x -> (acc, y)) -> acc -> Infinite x -> Infinite yinfinite-list Data.List.Infinite Same as mapAccumL, but strict in accumulator.
mapEither :: (a -> Either b c) -> Infinite a -> (Infinite b, Infinite c)infinite-list Data.List.Infinite Apply a function to every element of an infinite list and separate Left and Right results. This function isn't productive (e. g., head . fst . mapEither f won't terminate), if no elements of the input list result in Left or Right.
mapMaybe :: (a -> Maybe b) -> Infinite a -> Infinite binfinite-list Data.List.Infinite Apply a function to every element of an infinite list and collect Just results. This function isn't productive (e. g., head . mapMaybe f won't terminate), if no elements of the input list result in Just.
mapConcurrently :: (Traversable t, MonadBaseControl IO m) => (a -> m b) -> t a -> m (t b)lifted-async Control.Concurrent.Async.Lifted Generalized version of mapConcurrently.
mapConcurrently_ :: (Foldable t, MonadBaseControl IO m) => (a -> m b) -> t a -> m ()lifted-async Control.Concurrent.Async.Lifted Generalized version of mapConcurrently_.
-
lifted-async Control.Concurrent.Async.Lifted.Safe Generalized version of mapConcurrently.