Copyright | (C) Frank Staals |
---|---|
License | see the LICENSE file |
Maintainer | Frank Staals |
Safe Haskell | None |
Language | GHC2021 |
Things that have an index.
Synopsis
- class HasIndex a where
- type Index = Int
- data WithIndex a = WithIndex !Index a
- theValue :: forall a b f. Functor f => (a -> f b) -> WithIndex a -> f (WithIndex b)
- labelWithIndex :: Traversable t => t a -> t (WithIndex a)
- labelWith :: Traversable t => (Index -> a -> b) -> t a -> t b
- labelWith' :: Traversable t => (Index -> a -> b) -> t a -> (t b, Int)
Documentation
Associate a value of type a
with an Index.
theValue :: forall a b f. Functor f => (a -> f b) -> WithIndex a -> f (WithIndex b) Source #
Lens to manipulate the value of the WithIndex
labelWithIndex :: Traversable t => t a -> t (WithIndex a) Source #
Label each element with its index.
labelWith :: Traversable t => (Index -> a -> b) -> t a -> t b Source #
Label each element with its index using the given labelling function.
labelWith' :: Traversable t => (Index -> a -> b) -> t a -> (t b, Int) Source #
Label each element with its index using the given labelling function. Returns the new collection as well as its size.