Copyright | (c) Abhinav Gupta 2015 |
---|---|
License | BSD3 |
Maintainer | Abhinav Gupta <mail@abhinavg.net> |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
Pinch.Internal.FoldList
Description
Implements a representation of a list as a fold over it.
- data FoldList a
- map :: (a -> b) -> FoldList a -> FoldList b
- replicate :: Int -> a -> FoldList a
- replicateM :: Monad m => Int -> m a -> m (FoldList a)
- foldl' :: Foldable t => forall b a. (b -> a -> b) -> b -> t a -> b
- foldr :: Foldable t => forall a b. (a -> b -> b) -> b -> t a -> b
- toList :: Foldable t => forall a. t a -> [a]
- fromFoldable :: Foldable f => f a -> FoldList a
- fromMap :: (forall r. (r -> k -> v -> r) -> r -> m k v -> r) -> m k v -> FoldList (k, v)
- mapM :: Traversable t => forall a m b. Monad m => (a -> m b) -> t a -> m (t b)
- sequence :: Traversable t => forall m a. Monad m => t (m a) -> m (t a)
Documentation
FoldList represents a list as a foldl'
traversal over it.
This allows us to avoid allocating new collections for an intermediate representation of various data types that users provide.
map :: (a -> b) -> FoldList a -> FoldList b Source
Applies the given function to all elements in the FoldList.
Note that the function is applied lazily when the results are requested. If the results of the same FoldList are requested multiple times, the function will be called multiple times on the same elements.
replicateM :: Monad m => Int -> m a -> m (FoldList a) Source
Executes the given monadic action the given number of times and returns a FoldList of the results.
fromFoldable :: Foldable f => f a -> FoldList a Source
Builds a FoldList from a Foldable.
Arguments
:: (forall r. (r -> k -> v -> r) -> r -> m k v -> r) |
|
-> m k v | |
-> FoldList (k, v) |
Builds a FoldList over pairs of items of a map.
mapM :: Traversable t => forall a m b. Monad m => (a -> m b) -> t a -> m (t b)
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_
.
sequence :: Traversable t => forall m a. Monad m => t (m a) -> m (t a)
Evaluate each monadic action in the structure from left to
right, and collect the results. For a version that ignores the
results see sequence_
.