Portability | rank 2 types, MPTCs, TFs, flexible |
---|---|
Stability | provisional |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Safe Haskell | Safe-Inferred |
Combinators for working with Indexed
functions.
- class Indexable i k where
- indexed :: ((i -> a) -> b) -> k a b
- newtype Indexed i a b = Indexed {
- withIndex :: (i -> a) -> b
- (<.>) :: Indexable (i, j) k => Indexed i b c -> Indexed j a b -> k a c
- (<.) :: Indexable i k => Indexed i b c -> (a -> b) -> k a c
- (.>) :: Indexable i k => (b -> c) -> Indexed i a b -> k a c
- icompose :: Indexable k r => (i -> j -> k) -> Indexed i b c -> Indexed j a b -> r a c
- reindexed :: Indexable j k => (i -> j) -> Indexed i a b -> k a b
- indexing :: Indexable Int k => ((a -> Indexing f b) -> s -> Indexing f t) -> k (a -> f b) (s -> f t)
- indexing64 :: Indexable Int64 k => ((a -> Indexing64 f b) -> s -> Indexing64 f t) -> k (a -> f b) (s -> f t)
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.
Indexed Functions
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
.
(<.>) :: 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
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 bindexing
::Prism
s t a b ->IndexedTraversal
Int
s t a bindexing
::Lens
s t a b ->IndexedLens
Int
s t a bindexing
::Iso
s t a b ->IndexedLens
Int
s t a bindexing
::Fold
s t ->IndexedFold
Int
s tindexing
::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 Traversal
s and Fold
s gracefully.
indexing64
::Traversal
s t a b ->IndexedTraversal
Int64
s t a bindexing64
::Prism
s t a b ->IndexedTraversal
Int64
s t a bindexing64
::Lens
s t a b ->IndexedLens
Int64
s t a bindexing64
::Iso
s t a b ->IndexedLens
Int64
s t a bindexing64
::Fold
s t ->IndexedFold
Int64
s tindexing64
::Getter
s t ->IndexedGetter
Int64
s t a b