lens-1.4.1: Lenses, Folds and Traversals

Portabilityrank 2 types, MPTCs, TFs, flexible
Stabilityprovisional
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellSafe-Infered

Control.Indexed

Contents

Description

 

Synopsis

Overloading indexed functions

class Indexed i k whereSource

Permit overloading of function application for things that also admit a notion of a key or index.

Provides overloading for indexed functions.

Methods

index :: ((i -> a) -> b) -> k a bSource

Build a function from an indexed function

Instances

Indexed i (->) 
~ * i j => Indexed i (Index j)

Using an equality witness to avoid potential overlapping instances and aid dispatch.

type Indexable i a b = forall k. Indexed i k => k a bSource

Type alias for passing around polymorphic indexed functions.

newtype Index i a b Source

A function with access to a index. This constructor may be useful when you need to store a HasIndex.

Constructors

Index 

Fields

withIndex :: (i -> a) -> b
 

Instances

~ * i j => Indexed i (Index j)

Using an equality witness to avoid potential overlapping instances and aid dispatch.

(.@) :: Indexed (i, j) k => Index i b c -> Index j a b -> k a cSource

Composition of indexed functions

composeWithIndex :: Indexed k r => (i -> j -> k) -> Index i b c -> Index j a b -> r a cSource

Composition of indexed functions with a user supplied function for combining indexs

reindex :: Indexed j k => (i -> j) -> Index i a b -> k a bSource

Remap the index.