@hackage / indexed-traversable

FunctorWithIndex, FoldableWithIndex, TraversableWithIndex

Latest0.1.5

About

Metadata

  • Last updated , by phadej
  • License BSD-2-Clause
  • Maintained by: Oleg Grenrus <oleg.grenrus@iki.fi>

  • Lottery factor: 1

Links

Installation

Tested Compilers

  1. 9.10.1
  2. 9.8.4
  3. 9.6.6
  4. 9.4.8
  5. 9.2.8
  6. 9.0.2
  7. 8.10.7
  8. 8.8.4
  9. 8.6.5

Package Flags

Use the -f option with cabal commands to enable flags

    base-ge-4-18 (on by default)

    base >=4.18 (GHC-9.6)

Readme

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.