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 Indexed i k where
- index :: ((i -> a) -> b) -> k a b
- type Indexable i a b = forall k. Indexed i k => k a b
- newtype Index i a b = Index {
- withIndex :: (i -> a) -> b
- (<.>) :: Indexed (i, j) k => Index i b c -> Index j a b -> k a c
- (<.) :: Indexed i k => Index i b c -> (a -> b) -> k a c
- (.>) :: Indexed i k => (b -> c) -> Index i a b -> k a c
- icompose :: Indexed k r => (i -> j -> k) -> Index i b c -> Index j a b -> r a c
- reindex :: Indexed j k => (i -> j) -> Index i a b -> k a b
- indexed :: Indexed Int k => ((a -> Indexing f b) -> s -> Indexing f t) -> k (a -> f b) (s -> f t)
Indexed Functions
Permit overloading of function application for things that also admit a notion of a key or index.
Provides overloading for 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
.
(<.>) :: 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
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 bindexed
::Lens
s t a b ->IndexedLens
Int
s t a bindexed
::Fold
s t ->IndexedFold
Int
s tindexed
::Iso
s t a b ->IndexedLens
Int
s t a bindexed
::Getter
s t ->IndexedGetter
Int
s t a b