lens-3.7.2: 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

Documentation

class Indexable i k whereSource

This class permits overloading of function application for things that also admit a notion of a key or index.

Methods

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

Build a function from an Indexed function

Instances

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

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

Indexed Functions

newtype Indexed 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

Indexed 

Fields

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

Instances

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

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

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

Composition of Indexed functions

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

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

Compose an Indexed function with a non-indexed function.

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

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

Compose a non-indexed function with an Indexed function.

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

icompose :: Indexable k r => (i -> j -> k) -> Indexed i b c -> Indexed j a b -> r a cSource

Composition of Indexed functions with a user supplied function for combining indices

reindexed :: Indexable j k => (i -> j) -> Indexed i a b -> k a bSource

Remap the index.

Indexing existing lenses, traversals, etc.

indexing :: Indexable Int k => ((a -> Indexing f b) -> s -> Indexing f t) -> k (a -> f b) (s -> f t)Source

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

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

indexing64 :: Indexable Int64 k => ((a -> Indexing64 f b) -> s -> Indexing64 f t) -> k (a -> f b) (s -> f t)Source

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

This combinator is like indexing except that it handles large Traversals and Folds gracefully.

 indexing64 :: Traversal s t a b -> IndexedTraversal Int64 s t a b
 indexing64 :: Prism s t a b         -> IndexedTraversal Int64 s t a b
 indexing64 :: Lens s t a b           -> IndexedLens Int64 s t a b
 indexing64 :: Iso s t a b             -> IndexedLens Int64 s t a b
 indexing64 :: Fold s t               -> IndexedFold Int64 s t
 indexing64 :: Getter s t           -> IndexedGetter Int64 s t a b