Portability | rank 2 types, MPTCs, TFs, flexible |
---|---|
Stability | provisional |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Safe Haskell | Safe-Infered |
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 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 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.