Module

Data.FunctorWithIndex

Package
purescript-foldable-traversable
Repository
purescript/purescript-foldable-traversable

#FunctorWithIndex Source

class (Functor f) <= FunctorWithIndex i f | f -> i where

A Functor with an additional index. Instances must satisfy a modified form of the Functor laws

mapWithIndex (\_ a -> a) = identity
mapWithIndex f . mapWithIndex g = mapWithIndex (\i -> f i <<< g i)

and be compatible with the Functor instance

map f = mapWithIndex (const f)

Members

Instances

#mapDefault Source

mapDefault :: forall i f a b. FunctorWithIndex i f => (a -> b) -> f a -> f b

A default implementation of Functor's map in terms of mapWithIndex