Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Data.Key
Contents
- type family Key (f :: * -> *)
- class Functor f => Keyed f where
- (<#$>) :: Keyed f => (Key f -> a -> b) -> f a -> f b
- keyed :: Keyed f => f a -> f (Key f, a)
- class Functor f => Zip f where
- class (Keyed f, Zip f) => ZipWithKey f where
- class Lookup f => Indexable f where
- (!) :: Indexable f => f a -> Key f -> a
- class Lookup f where
- lookupDefault :: Indexable f => Key f -> f a -> Maybe a
- class Functor f => Adjustable f where
- class Foldable t => FoldableWithKey t where
- foldrWithKey' :: FoldableWithKey t => (Key t -> a -> b -> b) -> b -> t a -> b
- foldlWithKey' :: FoldableWithKey t => (b -> Key t -> a -> b) -> b -> t a -> b
- foldrWithKeyM :: (FoldableWithKey t, Monad m) => (Key t -> a -> b -> m b) -> b -> t a -> m b
- foldlWithKeyM :: (FoldableWithKey t, Monad m) => (b -> Key t -> a -> m b) -> b -> t a -> m b
- traverseWithKey_ :: (FoldableWithKey t, Applicative f) => (Key t -> a -> f b) -> t a -> f ()
- forWithKey_ :: (FoldableWithKey t, Applicative f) => t a -> (Key t -> a -> f b) -> f ()
- mapWithKeyM_ :: (FoldableWithKey t, Monad m) => (Key t -> a -> m b) -> t a -> m ()
- forWithKeyM_ :: (FoldableWithKey t, Monad m) => t a -> (Key t -> a -> m b) -> m ()
- concatMapWithKey :: FoldableWithKey t => (Key t -> a -> [b]) -> t a -> [b]
- anyWithKey :: FoldableWithKey t => (Key t -> a -> Bool) -> t a -> Bool
- allWithKey :: FoldableWithKey t => (Key t -> a -> Bool) -> t a -> Bool
- findWithKey :: FoldableWithKey t => (Key t -> a -> Bool) -> t a -> Maybe a
- class (Foldable1 t, FoldableWithKey t) => FoldableWithKey1 t where
- traverseWithKey1_ :: (FoldableWithKey1 t, Apply f) => (Key t -> a -> f b) -> t a -> f ()
- forWithKey1_ :: (FoldableWithKey1 t, Apply f) => t a -> (Key t -> a -> f b) -> f ()
- foldMapWithKeyDefault1 :: (FoldableWithKey1 t, Monoid m) => (Key t -> a -> m) -> t a -> m
- class (Keyed t, FoldableWithKey t, Traversable t) => TraversableWithKey t where
- forWithKey :: (TraversableWithKey t, Applicative f) => t a -> (Key t -> a -> f b) -> f (t b)
- forWithKeyM :: (TraversableWithKey t, Monad m) => t a -> (Key t -> a -> m b) -> m (t b)
- mapAccumWithKeyL :: TraversableWithKey t => (Key t -> a -> b -> (a, c)) -> a -> t b -> (a, t c)
- mapAccumWithKeyR :: TraversableWithKey t => (Key t -> a -> b -> (a, c)) -> a -> t b -> (a, t c)
- mapWithKeyDefault :: TraversableWithKey t => (Key t -> a -> b) -> t a -> t b
- foldMapWithKeyDefault :: (TraversableWithKey t, Monoid m) => (Key t -> a -> m) -> t a -> m
- class (Traversable1 t, FoldableWithKey1 t, TraversableWithKey t) => TraversableWithKey1 t where
- foldMapWithKey1Default :: (TraversableWithKey1 t, Semigroup m) => (Key t -> a -> m) -> t a -> m
Keys
type family Key (f :: * -> *) Source #
Instances
type Key [] Source # | |
type Key Maybe Source # | |
type Key Identity Source # | |
type Key NonEmpty Source # | |
type Key IntMap Source # | |
type Key Tree Source # | |
type Key Seq Source # | |
type Key ((->) a) Source # | |
type Key ((,) k) Source # | |
type Key (Array i) Source # | |
type Key (Map k) Source # | |
type Key (Cofree f) Source # | |
type Key (Free f) Source # | |
type Key (HashMap k) Source # | |
type Key (TracedT s w) Source # | |
type Key (IdentityT * m) Source # | |
type Key (Sum * f g) Source # | |
type Key (Product * f g) Source # | |
type Key (ReaderT * e m) Source # | |
type Key (Compose * * f g) Source # | |
Keyed functors
class Functor f => Keyed f where Source #
Minimal complete definition
Methods
mapWithKey :: (Key f -> a -> b) -> f a -> f b Source #
Instances
Keyed [] Source # | |
Keyed Maybe Source # | |
Keyed Identity Source # | |
Keyed NonEmpty Source # | |
Keyed IntMap Source # | |
Keyed Tree Source # | |
Keyed Seq Source # | |
Keyed ((->) a) Source # | |
Keyed ((,) k) Source # | |
Ix i => Keyed (Array i) Source # | |
Keyed (Map k) Source # | |
Keyed f => Keyed (Cofree f) Source # | |
Keyed f => Keyed (Free f) Source # | |
Keyed (HashMap k) Source # | |
Keyed w => Keyed (TracedT s w) Source # | |
Keyed m => Keyed (IdentityT * m) Source # | |
(Keyed f, Keyed g) => Keyed (Product * f g) Source # | |
Keyed m => Keyed (ReaderT * e m) Source # | |
(Keyed f, Keyed g) => Keyed (Compose * * f g) Source # | |
Zippable functors
class Functor f => Zip f where Source #
Instances
Zip [] Source # | |
Zip Maybe Source # | |
Zip Identity Source # | |
Zip NonEmpty Source # | |
Zip IntMap Source # | |
Zip Tree Source # | |
Zip Seq Source # | |
Zip ((->) a) Source # | |
Ord k => Zip (Map k) Source # | |
Zip f => Zip (Cofree f) Source # | |
(Eq k, Hashable k) => Zip (HashMap k) Source # | |
Zip w => Zip (TracedT s w) Source # | |
Zip m => Zip (IdentityT * m) Source # | |
(Zip f, Zip g) => Zip (Product * f g) Source # | |
Zip m => Zip (ReaderT * e m) Source # | |
(Zip f, Zip g) => Zip (Compose * * f g) Source # | |
Zipping keyed functors
class (Keyed f, Zip f) => ZipWithKey f where Source #
Methods
zipWithKey :: (Key f -> a -> b -> c) -> f a -> f b -> f c Source #
zapWithKey :: f (Key f -> a -> b) -> f a -> f b Source #
Instances
ZipWithKey [] Source # | |
ZipWithKey Maybe Source # | |
ZipWithKey Identity Source # | |
ZipWithKey NonEmpty Source # | |
ZipWithKey IntMap Source # | |
ZipWithKey Tree Source # | |
ZipWithKey Seq Source # | |
ZipWithKey ((->) a) Source # | |
Ord k => ZipWithKey (Map k) Source # | |
ZipWithKey f => ZipWithKey (Cofree f) Source # | |
(Eq k, Hashable k) => ZipWithKey (HashMap k) Source # | |
ZipWithKey w => ZipWithKey (TracedT s w) Source # | |
ZipWithKey m => ZipWithKey (IdentityT * m) Source # | |
(ZipWithKey f, ZipWithKey g) => ZipWithKey (Product * f g) Source # | |
ZipWithKey m => ZipWithKey (ReaderT * e m) Source # | |
(ZipWithKey f, ZipWithKey g) => ZipWithKey (Compose * * f g) Source # | |
Indexable functors
class Lookup f => Indexable f where Source #
Minimal complete definition
Instances
Indexable [] Source # | |
Indexable Maybe Source # | |
Indexable Identity Source # | |
Indexable NonEmpty Source # | |
Indexable IntMap Source # | |
Indexable Tree Source # | |
Indexable Seq Source # | |
Indexable ((->) a) Source # | |
Ix i => Indexable (Array i) Source # | |
Ord k => Indexable (Map k) Source # | |
Indexable f => Indexable (Cofree f) Source # | |
(Eq k, Hashable k) => Indexable (HashMap k) Source # | |
Indexable w => Indexable (TracedT s w) Source # | |
Indexable m => Indexable (IdentityT * m) Source # | |
(Indexable f, Indexable g) => Indexable (Sum * f g) Source # | |
(Indexable f, Indexable g) => Indexable (Product * f g) Source # | |
Indexable m => Indexable (ReaderT * e m) Source # | |
(Indexable f, Indexable g) => Indexable (Compose * * f g) Source # | |
Safe Lookup
Minimal complete definition
Instances
Lookup [] Source # | |
Lookup Maybe Source # | |
Lookup Identity Source # | |
Lookup NonEmpty Source # | |
Lookup IntMap Source # | |
Lookup Tree Source # | |
Lookup Seq Source # | |
Lookup ((->) a) Source # | |
Ix i => Lookup (Array i) Source # | |
Ord k => Lookup (Map k) Source # | |
Lookup f => Lookup (Cofree f) Source # | |
Lookup f => Lookup (Free f) Source # | |
(Eq k, Hashable k) => Lookup (HashMap k) Source # | |
Lookup w => Lookup (TracedT s w) Source # | |
Lookup m => Lookup (IdentityT * m) Source # | |
(Lookup f, Lookup g) => Lookup (Sum * f g) Source # | |
(Lookup f, Lookup g) => Lookup (Product * f g) Source # | |
Lookup m => Lookup (ReaderT * e m) Source # | |
(Lookup f, Lookup g) => Lookup (Compose * * f g) Source # | |
Adjustable
class Functor f => Adjustable f where Source #
Minimal complete definition
Instances
Adjustable [] Source # | |
Adjustable Identity Source # | |
Adjustable NonEmpty Source # | |
Adjustable IntMap Source # | |
Adjustable Tree Source # | |
Adjustable Seq Source # | |
Ix i => Adjustable (Array i) Source # | |
Ord k => Adjustable (Map k) Source # | |
Adjustable f => Adjustable (Cofree f) Source # | |
Adjustable f => Adjustable (Free f) Source # | |
(Adjustable f, Adjustable g) => Adjustable (Sum * f g) Source # | |
(Adjustable f, Adjustable g) => Adjustable (Product * f g) Source # | |
FoldableWithKey
class Foldable t => FoldableWithKey t where Source #
Methods
toKeyedList :: t a -> [(Key t, a)] Source #
foldMapWithKey :: Monoid m => (Key t -> a -> m) -> t a -> m Source #
foldrWithKey :: (Key t -> a -> b -> b) -> b -> t a -> b Source #
foldlWithKey :: (b -> Key t -> a -> b) -> b -> t a -> b Source #
Instances
FoldableWithKey [] Source # | |
FoldableWithKey Maybe Source # | |
FoldableWithKey Identity Source # | |
FoldableWithKey NonEmpty Source # | |
FoldableWithKey IntMap Source # | |
FoldableWithKey Tree Source # | |
FoldableWithKey Seq Source # | |
FoldableWithKey ((,) k) Source # | |
Ix i => FoldableWithKey (Array i) Source # | |
FoldableWithKey (Map k) Source # | |
FoldableWithKey f => FoldableWithKey (Cofree f) Source # | |
FoldableWithKey f => FoldableWithKey (Free f) Source # | |
FoldableWithKey (HashMap k) Source # | |
FoldableWithKey m => FoldableWithKey (IdentityT * m) Source # | |
(FoldableWithKey f, FoldableWithKey g) => FoldableWithKey (Product * f g) Source # | |
(FoldableWithKey f, FoldableWithKey m) => FoldableWithKey (Compose * * f m) Source # | |
foldrWithKey' :: FoldableWithKey t => (Key t -> a -> b -> b) -> b -> t a -> b Source #
foldlWithKey' :: FoldableWithKey t => (b -> Key t -> a -> b) -> b -> t a -> b Source #
foldrWithKeyM :: (FoldableWithKey t, Monad m) => (Key t -> a -> b -> m b) -> b -> t a -> m b Source #
foldlWithKeyM :: (FoldableWithKey t, Monad m) => (b -> Key t -> a -> m b) -> b -> t a -> m b Source #
traverseWithKey_ :: (FoldableWithKey t, Applicative f) => (Key t -> a -> f b) -> t a -> f () Source #
forWithKey_ :: (FoldableWithKey t, Applicative f) => t a -> (Key t -> a -> f b) -> f () Source #
mapWithKeyM_ :: (FoldableWithKey t, Monad m) => (Key t -> a -> m b) -> t a -> m () Source #
forWithKeyM_ :: (FoldableWithKey t, Monad m) => t a -> (Key t -> a -> m b) -> m () Source #
concatMapWithKey :: FoldableWithKey t => (Key t -> a -> [b]) -> t a -> [b] Source #
anyWithKey :: FoldableWithKey t => (Key t -> a -> Bool) -> t a -> Bool Source #
allWithKey :: FoldableWithKey t => (Key t -> a -> Bool) -> t a -> Bool Source #
findWithKey :: FoldableWithKey t => (Key t -> a -> Bool) -> t a -> Maybe a Source #
FoldableWithKey1
class (Foldable1 t, FoldableWithKey t) => FoldableWithKey1 t where Source #
Minimal complete definition
Methods
foldMapWithKey1 :: Semigroup m => (Key t -> a -> m) -> t a -> m Source #
Instances
FoldableWithKey1 Identity Source # | |
FoldableWithKey1 NonEmpty Source # | |
FoldableWithKey1 Tree Source # | |
FoldableWithKey1 ((,) k) Source # | |
FoldableWithKey1 f => FoldableWithKey1 (Cofree f) Source # | |
FoldableWithKey1 f => FoldableWithKey1 (Free f) Source # | |
FoldableWithKey1 m => FoldableWithKey1 (IdentityT * m) Source # | |
(FoldableWithKey1 f, FoldableWithKey1 g) => FoldableWithKey1 (Product * f g) Source # | |
(FoldableWithKey1 f, FoldableWithKey1 m) => FoldableWithKey1 (Compose * * f m) Source # | |
traverseWithKey1_ :: (FoldableWithKey1 t, Apply f) => (Key t -> a -> f b) -> t a -> f () Source #
forWithKey1_ :: (FoldableWithKey1 t, Apply f) => t a -> (Key t -> a -> f b) -> f () Source #
foldMapWithKeyDefault1 :: (FoldableWithKey1 t, Monoid m) => (Key t -> a -> m) -> t a -> m Source #
TraversableWithKey
class (Keyed t, FoldableWithKey t, Traversable t) => TraversableWithKey t where Source #
Minimal complete definition
Methods
traverseWithKey :: Applicative f => (Key t -> a -> f b) -> t a -> f (t b) Source #
mapWithKeyM :: Monad m => (Key t -> a -> m b) -> t a -> m (t b) Source #
Instances
TraversableWithKey [] Source # | |
TraversableWithKey Maybe Source # | |
TraversableWithKey Identity Source # | |
TraversableWithKey NonEmpty Source # | |
TraversableWithKey IntMap Source # | |
TraversableWithKey Tree Source # | |
TraversableWithKey Seq Source # | |
TraversableWithKey ((,) k) Source # | |
Ix i => TraversableWithKey (Array i) Source # | |
TraversableWithKey (Map k) Source # | |
TraversableWithKey f => TraversableWithKey (Cofree f) Source # | |
TraversableWithKey f => TraversableWithKey (Free f) Source # | |
TraversableWithKey (HashMap k) Source # | |
TraversableWithKey m => TraversableWithKey (IdentityT * m) Source # | |
(TraversableWithKey f, TraversableWithKey g) => TraversableWithKey (Product * f g) Source # | |
(TraversableWithKey f, TraversableWithKey m) => TraversableWithKey (Compose * * f m) Source # | |
forWithKey :: (TraversableWithKey t, Applicative f) => t a -> (Key t -> a -> f b) -> f (t b) Source #
forWithKeyM :: (TraversableWithKey t, Monad m) => t a -> (Key t -> a -> m b) -> m (t b) Source #
mapAccumWithKeyL :: TraversableWithKey t => (Key t -> a -> b -> (a, c)) -> a -> t b -> (a, t c) Source #
The mapAccumWithKeyL
function behaves like a combination of mapWithKey
and foldlWithKey
; it applies a function to each element of a structure,
passing an accumulating parameter from left to right, and returning
a final value of this accumulator together with the new structure.
mapAccumWithKeyR :: TraversableWithKey t => (Key t -> a -> b -> (a, c)) -> a -> t b -> (a, t c) Source #
The mapAccumWithKeyR
function behaves like a combination of mapWithKey
and foldrWithKey
; it applies a function to each element of a structure,
passing an accumulating parameter from right to left, and returning
a final value of this accumulator together with the new structure.
mapWithKeyDefault :: TraversableWithKey t => (Key t -> a -> b) -> t a -> t b Source #
foldMapWithKeyDefault :: (TraversableWithKey t, Monoid m) => (Key t -> a -> m) -> t a -> m Source #
This function may be used as a value for foldMapWithKey
in a FoldableWithKey
instance.
TraversableWithKey1
class (Traversable1 t, FoldableWithKey1 t, TraversableWithKey t) => TraversableWithKey1 t where Source #
Minimal complete definition
Methods
traverseWithKey1 :: Apply f => (Key t -> a -> f b) -> t a -> f (t b) Source #
Instances
TraversableWithKey1 Identity Source # | |
TraversableWithKey1 NonEmpty Source # | |
TraversableWithKey1 Tree Source # | |
TraversableWithKey1 ((,) k) Source # | |
TraversableWithKey1 f => TraversableWithKey1 (Cofree f) Source # | |
TraversableWithKey1 f => TraversableWithKey1 (Free f) Source # | |
TraversableWithKey1 m => TraversableWithKey1 (IdentityT * m) Source # | |
(TraversableWithKey1 f, TraversableWithKey1 g) => TraversableWithKey1 (Product * f g) Source # | |
(TraversableWithKey1 f, TraversableWithKey1 m) => TraversableWithKey1 (Compose * * f m) Source # | |
foldMapWithKey1Default :: (TraversableWithKey1 t, Semigroup m) => (Key t -> a -> m) -> t a -> m Source #