lens-3.3: Lenses, Folds and Traversals

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

Control.Lens.Indexed

Contents

Description

Combinators for working with Indexed functions.

Synopsis

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 that can be called withIndex or directly as a function

newtype Index i a b Source

A function with access to a index. This constructor may be useful when you need to store a Indexable in a container to avoid ImpredicativeTypes.

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

Mnemonically, the < and > points to the fact that we want to preserve the indices.

(<.) :: Indexed i k => Index i b c -> (a -> b) -> k a cSource

Compose an Indexed function with a non-indexed function.

Mnemonically, the < points to the index we want to preserve.

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

Compose a non-indexed function with an Indexed function.

Mnemonically, the > points to the index we want to preserve.

icompose :: 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.

indexed :: Indexed Int k => ((a -> Indexing f b) -> s -> Indexing f t) -> k (a -> f b) (s -> f t)Source

Transform an Traversal into an IndexedTraversal, a Fold into an IndexedFold, etc.

 indexed :: Traversal s t a b -> IndexedTraversal Int s t a b
 indexed :: Lens s t a b      -> IndexedLens Int s t a b
 indexed :: Fold s t          -> IndexedFold Int s t
 indexed :: Iso s t a b       -> IndexedLens Int s t a b
 indexed :: Getter s t        -> IndexedGetter Int s t a b