-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | FunctorWithIndex, FoldableWithIndex, TraversableWithIndex
--   
--   This package provides three useful generalizations:
--   
--   
--   class Functor f => FunctorWithIndex i f | f -> i where
--     imap :: (i -> a -> b) -> f a -> f b
--   
--   
--   
--   class Foldable f => FoldableWithIndex i f | f -> i where
--     ifoldMap :: Monoid m => (i -> a -> m) -> f a -> m
--   
--   
--   
--   class (FunctorWithIndex i t, FoldableWithIndex i t, Traversable t) => TraversableWithIndex i t | t -> i where
--     itraverse :: Applicative f => (i -> a -> f b) -> t a -> f (t b)
--   
--   
--   This package contains instances for types in GHC boot libraries. For
--   some additional instances see indexed-traversable-instances.
--   
--   The keys package provides similar functionality, but uses
--   (associated) TypeFamilies instead of
--   FunctionalDependencies.
@package indexed-traversable
@version 0.1.4

-- | Indexed Traversables
module Data.Traversable.WithIndex

-- | A Traversable with an additional index.
--   
--   An instance must satisfy a (modified) form of the Traversable
--   laws:
--   
--   
--   itraverse (const Identity) ≡ Identity
--   fmap (itraverse f) . itraverse g ≡ getCompose . itraverse (\i -> Compose . fmap (f i) . g i)
--   
class (FunctorWithIndex i t, FoldableWithIndex i t, Traversable t) => TraversableWithIndex i (t :: Type -> Type) | t -> i

-- | Traverse an indexed container.
--   
--   
--   itraverse ≡ itraverseOf itraversed
--   
itraverse :: (TraversableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f (t b)
($dmitraverse) :: (TraversableWithIndex i t, i ~ Int, Applicative f) => (i -> a -> f b) -> t a -> f (t b)

-- | Traverse with an index (and the arguments flipped).
--   
--   
--   for a ≡ ifor a . const
--   ifor ≡ flip itraverse
--   
ifor :: (TraversableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f (t b)

-- | Map each element of a structure to a monadic action, evaluate these
--   actions from left to right, and collect the results, with access the
--   index.
--   
--   When you don't need access to the index mapM is more liberal
--   in what it can accept.
--   
--   
--   mapM ≡ imapM . const
--   
imapM :: (TraversableWithIndex i t, Monad m) => (i -> 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, with access its
--   position (and the arguments flipped).
--   
--   
--   forM a ≡ iforM a . const
--   iforM ≡ flip imapM
--   
iforM :: (TraversableWithIndex i t, Monad m) => t a -> (i -> a -> m b) -> m (t b)

-- | Generalizes mapAccumR to add access to the index.
--   
--   imapAccumR accumulates state from right to left.
--   
--   
--   mapAccumR ≡ imapAccumR . const
--   
imapAccumR :: TraversableWithIndex i t => (i -> s -> a -> (s, b)) -> s -> t a -> (s, t b)

-- | Generalizes mapAccumL to add access to the index.
--   
--   imapAccumL accumulates state from left to right.
--   
--   
--   mapAccumL ≡ imapAccumL . const
--   
imapAccumL :: TraversableWithIndex i t => (i -> s -> a -> (s, b)) -> s -> t a -> (s, t b)
imapDefault :: TraversableWithIndex i f => (i -> a -> b) -> f a -> f b
ifoldMapDefault :: (TraversableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m

module Data.Functor.WithIndex

-- | A Functor with an additional index.
--   
--   Instances must satisfy a modified form of the Functor laws:
--   
--   
--   imap f . imap g ≡ imap (\i -> f i . g i)
--   imap (\_ a -> a) ≡ id
--   
class Functor f => FunctorWithIndex i (f :: Type -> Type) | f -> i

-- | Map with access to the index.
imap :: FunctorWithIndex i f => (i -> a -> b) -> f a -> f b
($dmimap) :: (FunctorWithIndex i f, TraversableWithIndex i f) => (i -> a -> b) -> f a -> f b

-- | Indexed non-empty Foldables.
module Data.Foldable1.WithIndex

-- | A non-empty container that supports folding with an additional index.
class (Foldable1 f, FoldableWithIndex i f) => Foldable1WithIndex i (f :: Type -> Type) | f -> i

-- | Map each element of the structure to a semigroup, and combine the
--   results.
ifoldMap1 :: (Foldable1WithIndex i f, Semigroup m) => (i -> a -> m) -> f a -> m

-- | A variant of ifoldMap1 that is strict in the accumulator.
ifoldMap1' :: (Foldable1WithIndex i f, Semigroup m) => (i -> a -> m) -> f a -> m

-- | Generalized ifoldr1.
ifoldrMap1 :: Foldable1WithIndex i f => (i -> a -> b) -> (i -> a -> b -> b) -> f a -> b

-- | Generalized ifoldl1'.
ifoldlMap1' :: Foldable1WithIndex i f => (i -> a -> b) -> (i -> b -> a -> b) -> f a -> b

-- | Generalized ifoldl1.
ifoldlMap1 :: Foldable1WithIndex i f => (i -> a -> b) -> (i -> b -> a -> b) -> f a -> b

-- | Generalized ifoldr1'.
ifoldrMap1' :: Foldable1WithIndex i f => (i -> a -> b) -> (i -> a -> b -> b) -> f a -> b

-- | Indexed Foldables.
module Data.Foldable.WithIndex

-- | A container that supports folding with an additional index.
class Foldable f => FoldableWithIndex i (f :: Type -> Type) | f -> i

-- | Fold a container by mapping value to an arbitrary Monoid with
--   access to the index i.
--   
--   When you don't need access to the index then foldMap is more
--   flexible in what it accepts.
--   
--   
--   foldMap ≡ ifoldMap . const
--   
ifoldMap :: (FoldableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m
($dmifoldMap) :: (FoldableWithIndex i f, TraversableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m

-- | A variant of ifoldMap that is strict in the accumulator.
--   
--   When you don't need access to the index then foldMap' is more
--   flexible in what it accepts.
--   
--   
--   foldMap' ≡ ifoldMap' . const
--   
ifoldMap' :: (FoldableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m

-- | Right-associative fold of an indexed container with access to the
--   index i.
--   
--   When you don't need access to the index then foldr is more
--   flexible in what it accepts.
--   
--   
--   foldr ≡ ifoldr . const
--   
ifoldr :: FoldableWithIndex i f => (i -> a -> b -> b) -> b -> f a -> b

-- | Left-associative fold of an indexed container with access to the index
--   i.
--   
--   When you don't need access to the index then foldl is more
--   flexible in what it accepts.
--   
--   
--   foldl ≡ ifoldl . const
--   
ifoldl :: FoldableWithIndex i f => (i -> b -> a -> b) -> b -> f a -> b

-- | Strictly fold right over the elements of a structure with
--   access to the index i.
--   
--   When you don't need access to the index then foldr' is more
--   flexible in what it accepts.
--   
--   
--   foldr' ≡ ifoldr' . const
--   
ifoldr' :: FoldableWithIndex i f => (i -> a -> b -> b) -> b -> f a -> b

-- | Fold over the elements of a structure with an index, associating to
--   the left, but strictly.
--   
--   When you don't need access to the index then foldlOf' is more
--   flexible in what it accepts.
--   
--   
--   foldl' l ≡ ifoldl' l . const
--   
ifoldl' :: FoldableWithIndex i f => (i -> b -> a -> b) -> b -> f a -> b

-- | Return whether or not any element in a container satisfies a
--   predicate, with access to the index i.
--   
--   When you don't need access to the index then any is more
--   flexible in what it accepts.
--   
--   
--   any ≡ iany . const
--   
iany :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool

-- | Return whether or not all elements in a container satisfy a predicate,
--   with access to the index i.
--   
--   When you don't need access to the index then all is more
--   flexible in what it accepts.
--   
--   
--   all ≡ iall . const
--   
iall :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool

-- | Return whether or not none of the elements in a container satisfy a
--   predicate, with access to the index i.
--   
--   When you don't need access to the index then none is more
--   flexible in what it accepts.
--   
--   
--   none ≡ inone . const
--   inone f ≡ not . iany f
--   
inone :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool

-- | Determines whether no elements of the structure satisfy the predicate.
--   
--   
--   none f ≡ not . any f
--   
none :: Foldable f => (a -> Bool) -> f a -> Bool

-- | Traverse elements with access to the index i, discarding the
--   results.
--   
--   When you don't need access to the index then traverse_ is
--   more flexible in what it accepts.
--   
--   
--   traverse_ l = itraverse . const
--   
itraverse_ :: (FoldableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f ()

-- | Traverse elements with access to the index i, discarding the
--   results (with the arguments flipped).
--   
--   
--   ifor_ ≡ flip itraverse_
--   
--   
--   When you don't need access to the index then for_ is more
--   flexible in what it accepts.
--   
--   
--   for_ a ≡ ifor_ a . const
--   
ifor_ :: (FoldableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f ()

-- | Run monadic actions for each target of an IndexedFold or
--   IndexedTraversal with access to the index, discarding the
--   results.
--   
--   When you don't need access to the index then mapMOf_ is more
--   flexible in what it accepts.
--   
--   
--   mapM_ ≡ imapM . const
--   
imapM_ :: (FoldableWithIndex i t, Monad m) => (i -> a -> m b) -> t a -> m ()

-- | Run monadic actions for each target of an IndexedFold or
--   IndexedTraversal with access to the index, discarding the
--   results (with the arguments flipped).
--   
--   
--   iforM_ ≡ flip imapM_
--   
--   
--   When you don't need access to the index then forM_ is more
--   flexible in what it accepts.
--   
--   
--   forM_ a ≡ iforM a . const
--   
iforM_ :: (FoldableWithIndex i t, Monad m) => t a -> (i -> a -> m b) -> m ()

-- | Concatenate the results of a function of the elements of an indexed
--   container with access to the index.
--   
--   When you don't need access to the index then concatMap is
--   more flexible in what it accepts.
--   
--   
--   concatMap ≡ iconcatMap . const
--   iconcatMap ≡ ifoldMap
--   
iconcatMap :: FoldableWithIndex i f => (i -> a -> [b]) -> f a -> [b]

-- | Searches a container with a predicate that is also supplied the index,
--   returning the left-most element of the structure matching the
--   predicate, or Nothing if there is no such element.
--   
--   When you don't need access to the index then find is more
--   flexible in what it accepts.
--   
--   
--   find ≡ ifind . const
--   
ifind :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Maybe (i, a)

-- | Monadic fold right over the elements of a structure with an index.
--   
--   When you don't need access to the index then foldrM is more
--   flexible in what it accepts.
--   
--   
--   foldrM ≡ ifoldrM . const
--   
ifoldrM :: (FoldableWithIndex i f, Monad m) => (i -> a -> b -> m b) -> b -> f a -> m b

-- | Monadic fold over the elements of a structure with an index,
--   associating to the left.
--   
--   When you don't need access to the index then foldlM is more
--   flexible in what it accepts.
--   
--   
--   foldlM ≡ ifoldlM . const
--   
ifoldlM :: (FoldableWithIndex i f, Monad m) => (i -> b -> a -> m b) -> b -> f a -> m b

-- | Extract the key-value pairs from a structure.
--   
--   When you don't need access to the indices in the result, then
--   toList is more flexible in what it accepts.
--   
--   
--   toList ≡ map snd . itoList
--   
itoList :: FoldableWithIndex i f => f a -> [(i, a)]
