keys-3.11: Keyed functors and containers

Safe Haskell | Safe
Language | Haskell98

Data.Key

Contents

- Keys
- Keyed functors
- Zippable functors
- Zipping keyed functors
- Indexable functors
- Safe Lookup
- Adjustable
- FoldableWithKey
- FoldableWithKey1
- TraversableWithKey
- TraversableWithKey1

Synopsis

- 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 :: * -> *) #

Instances

type Key [] # |
type Key [] = Int
type Key Maybe # |
type Key Maybe = ()
type Key Identity # |
type Key Identity = ()
type Key NonEmpty # |
type Key NonEmpty = Int
type Key Tree # |
type Key Tree = Seq Int
type Key Seq # |
type Key Seq = Int
type Key IntMap # |
type Key IntMap = Int
type Key ((->) a) # |
type Key ((->) a) = a
type Key ((,) k) # |
type Key ((,) k) = k
type Key (Array i) # |
type Key (Array i) = i
type Key (Map k) # |
type Key (Map k) = k
type Key (Cofree f) # |
type Key (Cofree f) = Seq (Key f)
type Key (Free f) # |
type Key (Free f) = Seq (Key f)
type Key (HashMap k) # |
type Key (HashMap k) = k
type Key (TracedT s w) # |
type Key (TracedT s w) = (s, Key w)
type Key (IdentityT * m) # |
type Key (IdentityT * m) = Key m
type Key (Sum * f g) # |
type Key (Sum * f g) = (Key f, Key g)
type Key (Product * f g) # |
type Key (Product * f g) = Either (Key f) (Key g)
type Key (ReaderT * e m) # |
type Key (ReaderT * e m) = (e, Key m)
type Key (Compose * * f g) # |
type Key (Compose * * f g) = (Key f, Key g)

# Keyed functors

class Functor f => Keyed f where #

Minimal complete definition

mapWithKey

Methods

mapWithKey :: (Key f -> a -> b) -> f a -> f b #

Instances

Keyed [] # |
Methods mapWithKey :: (Key [] -> a -> b) -> [a] -> [b] #
Keyed Maybe # |
Methods mapWithKey :: (Key Maybe -> a -> b) -> Maybe a -> Maybe b #
Keyed Identity # |
Methods mapWithKey :: (Key Identity -> a -> b) -> Identity a -> Identity b #
Keyed NonEmpty # |
Methods mapWithKey :: (Key NonEmpty -> a -> b) -> NonEmpty a -> NonEmpty b #
Keyed Tree # |
Methods mapWithKey :: (Key Tree -> a -> b) -> Tree a -> Tree b #
Keyed Seq # |
Methods mapWithKey :: (Key Seq -> a -> b) -> Seq a -> Seq b #
Keyed IntMap # |
Methods mapWithKey :: (Key IntMap -> a -> b) -> IntMap a -> IntMap b #
Keyed ((->) a) # |
Methods mapWithKey :: (Key ((->) a) -> a -> b) -> (a -> a) -> a -> b #
Keyed ((,) k) # |
Methods mapWithKey :: (Key ((,) k) -> a -> b) -> (k, a) -> (k, b) #
Ix i => Keyed (Array i) # |
Methods mapWithKey :: (Key (Array i) -> a -> b) -> Array i a -> Array i b #
Keyed (Map k) # |
Methods mapWithKey :: (Key (Map k) -> a -> b) -> Map k a -> Map k b #
Keyed f => Keyed (Cofree f) # |
Methods mapWithKey :: (Key (Cofree f) -> a -> b) -> Cofree f a -> Cofree f b #
Keyed f => Keyed (Free f) # |
Methods mapWithKey :: (Key (Free f) -> a -> b) -> Free f a -> Free f b #
Keyed (HashMap k) # |
Methods mapWithKey :: (Key (HashMap k) -> a -> b) -> HashMap k a -> HashMap k b #
Keyed w => Keyed (TracedT s w) # |
Methods mapWithKey :: (Key (TracedT s w) -> a -> b) -> TracedT s w a -> TracedT s w b #
Keyed m => Keyed (IdentityT * m) # |
Methods mapWithKey :: (Key (IdentityT * m) -> a -> b) -> IdentityT * m a -> IdentityT * m b #
(Keyed f, Keyed g) => Keyed (Product * f g) # |
Methods mapWithKey :: (Key (Product * f g) -> a -> b) -> Product * f g a -> Product * f g b #
Keyed m => Keyed (ReaderT * e m) # |
Methods mapWithKey :: (Key (ReaderT * e m) -> a -> b) -> ReaderT * e m a -> ReaderT * e m b #
(Keyed f, Keyed g) => Keyed (Compose * * f g) # |
Methods mapWithKey :: (Key (Compose * * f g) -> a -> b) -> Compose * * f g a -> Compose * * f g b #

(<#$>) :: Keyed f => (Key f -> a -> b) -> f a -> f b infixl 4 #

keyed :: Keyed f => f a -> f (Key f, a) #

# Zippable functors

class Functor f => Zip f where #

Methods

zipWith :: (a -> b -> c) -> f a -> f b -> f c #

zip :: f a -> f b -> f (a, b) #

zap :: f (a -> b) -> f a -> f b #

Instances

Zip [] # |
Methods zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] # zip :: [a] -> [b] -> [(a, b)] # zap :: [a -> b] -> [a] -> [b] #
Zip Maybe # |
Methods zipWith :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c # zip :: Maybe a -> Maybe b -> Maybe (a, b) # zap :: Maybe (a -> b) -> Maybe a -> Maybe b #
Zip Identity # |
Methods zipWith :: (a -> b -> c) -> Identity a -> Identity b -> Identity c # zip :: Identity a -> Identity b -> Identity (a, b) # zap :: Identity (a -> b) -> Identity a -> Identity b #
Zip NonEmpty # |
Methods zipWith :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c # zip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b) # zap :: NonEmpty (a -> b) -> NonEmpty a -> NonEmpty b #
Zip Tree # |
Methods zipWith :: (a -> b -> c) -> Tree a -> Tree b -> Tree c # zip :: Tree a -> Tree b -> Tree (a, b) # zap :: Tree (a -> b) -> Tree a -> Tree b #
Zip Seq # |
Methods zipWith :: (a -> b -> c) -> Seq a -> Seq b -> Seq c # zip :: Seq a -> Seq b -> Seq (a, b) # zap :: Seq (a -> b) -> Seq a -> Seq b #
Zip IntMap # |
Methods zipWith :: (a -> b -> c) -> IntMap a -> IntMap b -> IntMap c # zip :: IntMap a -> IntMap b -> IntMap (a, b) # zap :: IntMap (a -> b) -> IntMap a -> IntMap b #
Zip ((->) a) # |
Methods zipWith :: (a -> b -> c) -> (a -> a) -> (a -> b) -> a -> c # zip :: (a -> a) -> (a -> b) -> a -> (a, b) # zap :: (a -> a -> b) -> (a -> a) -> a -> b #
Ord k => Zip (Map k) # |
Methods zipWith :: (a -> b -> c) -> Map k a -> Map k b -> Map k c # zip :: Map k a -> Map k b -> Map k (a, b) # zap :: Map k (a -> b) -> Map k a -> Map k b #
Zip f => Zip (Cofree f) # |
Methods zipWith :: (a -> b -> c) -> Cofree f a -> Cofree f b -> Cofree f c # zip :: Cofree f a -> Cofree f b -> Cofree f (a, b) # zap :: Cofree f (a -> b) -> Cofree f a -> Cofree f b #
(Eq k, Hashable k) => Zip (HashMap k) # |
Methods zipWith :: (a -> b -> c) -> HashMap k a -> HashMap k b -> HashMap k c # zip :: HashMap k a -> HashMap k b -> HashMap k (a, b) # zap :: HashMap k (a -> b) -> HashMap k a -> HashMap k b #
Zip w => Zip (TracedT s w) # |
Methods zipWith :: (a -> b -> c) -> TracedT s w a -> TracedT s w b -> TracedT s w c # zip :: TracedT s w a -> TracedT s w b -> TracedT s w (a, b) # zap :: TracedT s w (a -> b) -> TracedT s w a -> TracedT s w b #
Zip m => Zip (IdentityT * m) # |
Methods zipWith :: (a -> b -> c) -> IdentityT * m a -> IdentityT * m b -> IdentityT * m c # zip :: IdentityT * m a -> IdentityT * m b -> IdentityT * m (a, b) # zap :: IdentityT * m (a -> b) -> IdentityT * m a -> IdentityT * m b #
(Zip f, Zip g) => Zip (Product * f g) # |
Methods zipWith :: (a -> b -> c) -> Product * f g a -> Product * f g b -> Product * f g c # zip :: Product * f g a -> Product * f g b -> Product * f g (a, b) # zap :: Product * f g (a -> b) -> Product * f g a -> Product * f g b #
Zip m => Zip (ReaderT * e m) # |
Methods zipWith :: (a -> b -> c) -> ReaderT * e m a -> ReaderT * e m b -> ReaderT * e m c # zip :: ReaderT * e m a -> ReaderT * e m b -> ReaderT * e m (a, b) # zap :: ReaderT * e m (a -> b) -> ReaderT * e m a -> ReaderT * e m b #
(Zip f, Zip g) => Zip (Compose * * f g) # |
Methods zipWith :: (a -> b -> c) -> Compose * * f g a -> Compose * * f g b -> Compose * * f g c # zip :: Compose * * f g a -> Compose * * f g b -> Compose * * f g (a, b) # zap :: Compose * * f g (a -> b) -> Compose * * f g a -> Compose * * f g b #

# Zipping keyed functors

class (Keyed f, Zip f) => ZipWithKey f where #

Methods

zipWithKey :: (Key f -> a -> b -> c) -> f a -> f b -> f c #

zapWithKey :: f (Key f -> a -> b) -> f a -> f b #

Instances

ZipWithKey [] # |
Methods zipWithKey :: (Key [] -> a -> b -> c) -> [a] -> [b] -> [c] # zapWithKey :: [Key [] -> a -> b] -> [a] -> [b] #
ZipWithKey Maybe # |
Methods zipWithKey :: (Key Maybe -> a -> b -> c) -> Maybe a -> Maybe b -> Maybe c # zapWithKey :: Maybe (Key Maybe -> a -> b) -> Maybe a -> Maybe b #
ZipWithKey Identity # |
Methods zipWithKey :: (Key Identity -> a -> b -> c) -> Identity a -> Identity b -> Identity c # zapWithKey :: Identity (Key Identity -> a -> b) -> Identity a -> Identity b #
ZipWithKey NonEmpty # |
Methods zipWithKey :: (Key NonEmpty -> a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c # zapWithKey :: NonEmpty (Key NonEmpty -> a -> b) -> NonEmpty a -> NonEmpty b #
ZipWithKey Tree # |
Methods zipWithKey :: (Key Tree -> a -> b -> c) -> Tree a -> Tree b -> Tree c # zapWithKey :: Tree (Key Tree -> a -> b) -> Tree a -> Tree b #
ZipWithKey Seq # |
Methods zipWithKey :: (Key Seq -> a -> b -> c) -> Seq a -> Seq b -> Seq c # zapWithKey :: Seq (Key Seq -> a -> b) -> Seq a -> Seq b #
ZipWithKey IntMap # |
Methods zipWithKey :: (Key IntMap -> a -> b -> c) -> IntMap a -> IntMap b -> IntMap c # zapWithKey :: IntMap (Key IntMap -> a -> b) -> IntMap a -> IntMap b #
ZipWithKey ((->) a) # |
Methods zipWithKey :: (Key ((->) a) -> a -> b -> c) -> (a -> a) -> (a -> b) -> a -> c # zapWithKey :: (a -> Key ((->) a) -> a -> b) -> (a -> a) -> a -> b #
Ord k => ZipWithKey (Map k) # |
Methods zipWithKey :: (Key (Map k) -> a -> b -> c) -> Map k a -> Map k b -> Map k c # zapWithKey :: Map k (Key (Map k) -> a -> b) -> Map k a -> Map k b #
ZipWithKey f => ZipWithKey (Cofree f) # |
Methods zipWithKey :: (Key (Cofree f) -> a -> b -> c) -> Cofree f a -> Cofree f b -> Cofree f c # zapWithKey :: Cofree f (Key (Cofree f) -> a -> b) -> Cofree f a -> Cofree f b #
(Eq k, Hashable k) => ZipWithKey (HashMap k) # |
Methods zipWithKey :: (Key (HashMap k) -> a -> b -> c) -> HashMap k a -> HashMap k b -> HashMap k c # zapWithKey :: HashMap k (Key (HashMap k) -> a -> b) -> HashMap k a -> HashMap k b #
ZipWithKey w => ZipWithKey (TracedT s w) # |
Methods zipWithKey :: (Key (TracedT s w) -> a -> b -> c) -> TracedT s w a -> TracedT s w b -> TracedT s w c # zapWithKey :: TracedT s w (Key (TracedT s w) -> a -> b) -> TracedT s w a -> TracedT s w b #
ZipWithKey m => ZipWithKey (IdentityT * m) # |
Methods zipWithKey :: (Key (IdentityT * m) -> a -> b -> c) -> IdentityT * m a -> IdentityT * m b -> IdentityT * m c # zapWithKey :: IdentityT * m (Key (IdentityT * m) -> a -> b) -> IdentityT * m a -> IdentityT * m b #
(ZipWithKey f, ZipWithKey g) => ZipWithKey (Product * f g) # |
Methods zipWithKey :: (Key (Product * f g) -> a -> b -> c) -> Product * f g a -> Product * f g b -> Product * f g c # zapWithKey :: Product * f g (Key (Product * f g) -> a -> b) -> Product * f g a -> Product * f g b #
ZipWithKey m => ZipWithKey (ReaderT * e m) # |
Methods zipWithKey :: (Key (ReaderT * e m) -> a -> b -> c) -> ReaderT * e m a -> ReaderT * e m b -> ReaderT * e m c # zapWithKey :: ReaderT * e m (Key (ReaderT * e m) -> a -> b) -> ReaderT * e m a -> ReaderT * e m b #
(ZipWithKey f, ZipWithKey g) => ZipWithKey (Compose * * f g) # |
Methods zipWithKey :: (Key (Compose * * f g) -> a -> b -> c) -> Compose * * f g a -> Compose * * f g b -> Compose * * f g c # zapWithKey :: Compose * * f g (Key (Compose * * f g) -> a -> b) -> Compose * * f g a -> Compose * * f g b #

# Indexable functors

class Lookup f => Indexable f where #

Minimal complete definition

index

Methods

index :: f a -> Key f -> a #

Instances

Indexable [] # |
Methods index :: [a] -> Key [] -> a #
Indexable Maybe # |
Methods index :: Maybe a -> Key Maybe -> a #
Indexable Identity # |
Methods index :: Identity a -> Key Identity -> a #
Indexable NonEmpty # |
Methods index :: NonEmpty a -> Key NonEmpty -> a #
Indexable Tree # |
Methods index :: Tree a -> Key Tree -> a #
Indexable Seq # |
Methods index :: Seq a -> Key Seq -> a #
Indexable IntMap # |
Methods index :: IntMap a -> Key IntMap -> a #
Indexable ((->) a) # |
Methods index :: (a -> a) -> Key ((->) a) -> a #
Ix i => Indexable (Array i) # |
Methods index :: Array i a -> Key (Array i) -> a #
Ord k => Indexable (Map k) # |
Methods index :: Map k a -> Key (Map k) -> a #
Indexable f => Indexable (Cofree f) # |
Methods index :: Cofree f a -> Key (Cofree f) -> a #
(Eq k, Hashable k) => Indexable (HashMap k) # |
Methods index :: HashMap k a -> Key (HashMap k) -> a #
Indexable w => Indexable (TracedT s w) # |
Methods index :: TracedT s w a -> Key (TracedT s w) -> a #
Indexable m => Indexable (IdentityT * m) # |
Methods index :: IdentityT * m a -> Key (IdentityT * m) -> a #
(Indexable f, Indexable g) => Indexable (Sum * f g) # |
Methods index :: Sum * f g a -> Key (Sum * f g) -> a #
(Indexable f, Indexable g) => Indexable (Product * f g) # |
Methods index :: Product * f g a -> Key (Product * f g) -> a #
Indexable m => Indexable (ReaderT * e m) # |
Methods index :: ReaderT * e m a -> Key (ReaderT * e m) -> a #
(Indexable f, Indexable g) => Indexable (Compose * * f g) # |
Methods index :: Compose * * f g a -> Key (Compose * * f g) -> a #

(!) :: Indexable f => f a -> Key f -> a #

# Safe Lookup

class Lookup f where #

Minimal complete definition

lookup

Methods

lookup :: Key f -> f a -> Maybe a #

Instances

Lookup [] # |
Methods lookup :: Key [] -> [a] -> Maybe a #
Lookup Maybe # |
Methods lookup :: Key Maybe -> Maybe a -> Maybe a #
Lookup Identity # |
Methods lookup :: Key Identity -> Identity a -> Maybe a #
Lookup NonEmpty # |
Methods lookup :: Key NonEmpty -> NonEmpty a -> Maybe a #
Lookup Tree # |
Methods lookup :: Key Tree -> Tree a -> Maybe a #
Lookup Seq # |
Methods lookup :: Key Seq -> Seq a -> Maybe a #
Lookup IntMap # |
Methods lookup :: Key IntMap -> IntMap a -> Maybe a #
Lookup ((->) a) # |
Methods lookup :: Key ((->) a) -> (a -> a) -> Maybe a #
Ix i => Lookup (Array i) # |
Methods lookup :: Key (Array i) -> Array i a -> Maybe a #
Ord k => Lookup (Map k) # |
Methods lookup :: Key (Map k) -> Map k a -> Maybe a #
Lookup f => Lookup (Cofree f) # |
Methods lookup :: Key (Cofree f) -> Cofree f a -> Maybe a #
Lookup f => Lookup (Free f) # |
Methods lookup :: Key (Free f) -> Free f a -> Maybe a #
(Eq k, Hashable k) => Lookup (HashMap k) # |
Methods lookup :: Key (HashMap k) -> HashMap k a -> Maybe a #
Lookup w => Lookup (TracedT s w) # |
Methods lookup :: Key (TracedT s w) -> TracedT s w a -> Maybe a #
Lookup m => Lookup (IdentityT * m) # |
Methods lookup :: Key (IdentityT * m) -> IdentityT * m a -> Maybe a #
(Lookup f, Lookup g) => Lookup (Sum * f g) # |
Methods lookup :: Key (Sum * f g) -> Sum * f g a -> Maybe a #
(Lookup f, Lookup g) => Lookup (Product * f g) # |
Methods lookup :: Key (Product * f g) -> Product * f g a -> Maybe a #
Lookup m => Lookup (ReaderT * e m) # |
Methods lookup :: Key (ReaderT * e m) -> ReaderT * e m a -> Maybe a #
(Lookup f, Lookup g) => Lookup (Compose * * f g) # |
Methods lookup :: Key (Compose * * f g) -> Compose * * f g a -> Maybe a #

lookupDefault :: Indexable f => Key f -> f a -> Maybe a #

# Adjustable

class Functor f => Adjustable f where #

Minimal complete definition

adjust

Methods

adjust :: (a -> a) -> Key f -> f a -> f a #

replace :: Key f -> a -> f a -> f a #

Instances

Adjustable [] # |
Methods adjust :: (a -> a) -> Key [] -> [a] -> [a] # replace :: Key [] -> a -> [a] -> [a] #
Adjustable Identity # |
Methods adjust :: (a -> a) -> Key Identity -> Identity a -> Identity a # replace :: Key Identity -> a -> Identity a -> Identity a #
Adjustable NonEmpty # |
Methods adjust :: (a -> a) -> Key NonEmpty -> NonEmpty a -> NonEmpty a # replace :: Key NonEmpty -> a -> NonEmpty a -> NonEmpty a #
Adjustable Tree # |
Methods adjust :: (a -> a) -> Key Tree -> Tree a -> Tree a # replace :: Key Tree -> a -> Tree a -> Tree a #
Adjustable Seq # |
Methods adjust :: (a -> a) -> Key Seq -> Seq a -> Seq a # replace :: Key Seq -> a -> Seq a -> Seq a #
Adjustable IntMap # |
Methods adjust :: (a -> a) -> Key IntMap -> IntMap a -> IntMap a # replace :: Key IntMap -> a -> IntMap a -> IntMap a #
Ix i => Adjustable (Array i) # |
Methods adjust :: (a -> a) -> Key (Array i) -> Array i a -> Array i a # replace :: Key (Array i) -> a -> Array i a -> Array i a #
Ord k => Adjustable (Map k) # |
Methods adjust :: (a -> a) -> Key (Map k) -> Map k a -> Map k a # replace :: Key (Map k) -> a -> Map k a -> Map k a #
Adjustable f => Adjustable (Cofree f) # |
Methods adjust :: (a -> a) -> Key (Cofree f) -> Cofree f a -> Cofree f a # replace :: Key (Cofree f) -> a -> Cofree f a -> Cofree f a #
Adjustable f => Adjustable (Free f) # |
Methods adjust :: (a -> a) -> Key (Free f) -> Free f a -> Free f a # replace :: Key (Free f) -> a -> Free f a -> Free f a #
(Adjustable f, Adjustable g) => Adjustable (Sum * f g) # |
Methods adjust :: (a -> a) -> Key (Sum * f g) -> Sum * f g a -> Sum * f g a # replace :: Key (Sum * f g) -> a -> Sum * f g a -> Sum * f g a #
(Adjustable f, Adjustable g) => Adjustable (Product * f g) # |
Methods adjust :: (a -> a) -> Key (Product * f g) -> Product * f g a -> Product * f g a # replace :: Key (Product * f g) -> a -> Product * f g a -> Product * f g a #

# FoldableWithKey

class Foldable t => FoldableWithKey t where #

Methods

toKeyedList :: t a -> [(Key t, a)] #

foldMapWithKey :: Monoid m => (Key t -> a -> m) -> t a -> m #

foldrWithKey :: (Key t -> a -> b -> b) -> b -> t a -> b #

foldlWithKey :: (b -> Key t -> a -> b) -> b -> t a -> b #

Instances

FoldableWithKey [] # |
Methods toKeyedList :: [a] -> [(Key [], a)] # foldMapWithKey :: Monoid m => (Key [] -> a -> m) -> [a] -> m # foldrWithKey :: (Key [] -> a -> b -> b) -> b -> [a] -> b # foldlWithKey :: (b -> Key [] -> a -> b) -> b -> [a] -> b #
FoldableWithKey Maybe # |
Methods toKeyedList :: Maybe a -> [(Key Maybe, a)] # foldMapWithKey :: Monoid m => (Key Maybe -> a -> m) -> Maybe a -> m # foldrWithKey :: (Key Maybe -> a -> b -> b) -> b -> Maybe a -> b # foldlWithKey :: (b -> Key Maybe -> a -> b) -> b -> Maybe a -> b #
FoldableWithKey Identity # |
Methods toKeyedList :: Identity a -> [(Key Identity, a)] # foldMapWithKey :: Monoid m => (Key Identity -> a -> m) -> Identity a -> m # foldrWithKey :: (Key Identity -> a -> b -> b) -> b -> Identity a -> b # foldlWithKey :: (b -> Key Identity -> a -> b) -> b -> Identity a -> b #
FoldableWithKey NonEmpty # |
Methods toKeyedList :: NonEmpty a -> [(Key NonEmpty, a)] # foldMapWithKey :: Monoid m => (Key NonEmpty -> a -> m) -> NonEmpty a -> m # foldrWithKey :: (Key NonEmpty -> a -> b -> b) -> b -> NonEmpty a -> b # foldlWithKey :: (b -> Key NonEmpty -> a -> b) -> b -> NonEmpty a -> b #
FoldableWithKey Tree # |
Methods toKeyedList :: Tree a -> [(Key Tree, a)] # foldMapWithKey :: Monoid m => (Key Tree -> a -> m) -> Tree a -> m # foldrWithKey :: (Key Tree -> a -> b -> b) -> b -> Tree a -> b # foldlWithKey :: (b -> Key Tree -> a -> b) -> b -> Tree a -> b #
FoldableWithKey Seq # |
Methods toKeyedList :: Seq a -> [(Key Seq, a)] # foldMapWithKey :: Monoid m => (Key Seq -> a -> m) -> Seq a -> m # foldrWithKey :: (Key Seq -> a -> b -> b) -> b -> Seq a -> b # foldlWithKey :: (b -> Key Seq -> a -> b) -> b -> Seq a -> b #
FoldableWithKey IntMap # |
Methods toKeyedList :: IntMap a -> [(Key IntMap, a)] # foldMapWithKey :: Monoid m => (Key IntMap -> a -> m) -> IntMap a -> m # foldrWithKey :: (Key IntMap -> a -> b -> b) -> b -> IntMap a -> b # foldlWithKey :: (b -> Key IntMap -> a -> b) -> b -> IntMap a -> b #
FoldableWithKey ((,) k) # |
Methods toKeyedList :: (k, a) -> [(Key ((,) k), a)] # foldMapWithKey :: Monoid m => (Key ((,) k) -> a -> m) -> (k, a) -> m # foldrWithKey :: (Key ((,) k) -> a -> b -> b) -> b -> (k, a) -> b # foldlWithKey :: (b -> Key ((,) k) -> a -> b) -> b -> (k, a) -> b #
Ix i => FoldableWithKey (Array i) # |
Methods toKeyedList :: Array i a -> [(Key (Array i), a)] # foldMapWithKey :: Monoid m => (Key (Array i) -> a -> m) -> Array i a -> m # foldrWithKey :: (Key (Array i) -> a -> b -> b) -> b -> Array i a -> b # foldlWithKey :: (b -> Key (Array i) -> a -> b) -> b -> Array i a -> b #
FoldableWithKey (Map k) # |
Methods toKeyedList :: Map k a -> [(Key (Map k), a)] # foldMapWithKey :: Monoid m => (Key (Map k) -> a -> m) -> Map k a -> m # foldrWithKey :: (Key (Map k) -> a -> b -> b) -> b -> Map k a -> b # foldlWithKey :: (b -> Key (Map k) -> a -> b) -> b -> Map k a -> b #
FoldableWithKey f => FoldableWithKey (Cofree f) # |
Methods toKeyedList :: Cofree f a -> [(Key (Cofree f), a)] # foldMapWithKey :: Monoid m => (Key (Cofree f) -> a -> m) -> Cofree f a -> m # foldrWithKey :: (Key (Cofree f) -> a -> b -> b) -> b -> Cofree f a -> b # foldlWithKey :: (b -> Key (Cofree f) -> a -> b) -> b -> Cofree f a -> b #
FoldableWithKey f => FoldableWithKey (Free f) # |
Methods toKeyedList :: Free f a -> [(Key (Free f), a)] # foldMapWithKey :: Monoid m => (Key (Free f) -> a -> m) -> Free f a -> m # foldrWithKey :: (Key (Free f) -> a -> b -> b) -> b -> Free f a -> b # foldlWithKey :: (b -> Key (Free f) -> a -> b) -> b -> Free f a -> b #
FoldableWithKey (HashMap k) # |
Methods toKeyedList :: HashMap k a -> [(Key (HashMap k), a)] # foldMapWithKey :: Monoid m => (Key (HashMap k) -> a -> m) -> HashMap k a -> m # foldrWithKey :: (Key (HashMap k) -> a -> b -> b) -> b -> HashMap k a -> b # foldlWithKey :: (b -> Key (HashMap k) -> a -> b) -> b -> HashMap k a -> b #
FoldableWithKey m => FoldableWithKey (IdentityT * m) # |
Methods toKeyedList :: IdentityT * m a -> [(Key (IdentityT * m), a)] # foldMapWithKey :: Monoid m => (Key (IdentityT * m) -> a -> m) -> IdentityT * m a -> m # foldrWithKey :: (Key (IdentityT * m) -> a -> b -> b) -> b -> IdentityT * m a -> b # foldlWithKey :: (b -> Key (IdentityT * m) -> a -> b) -> b -> IdentityT * m a -> b #
(FoldableWithKey f, FoldableWithKey g) => FoldableWithKey (Product * f g) # |
Methods toKeyedList :: Product * f g a -> [(Key (Product * f g), a)] # foldMapWithKey :: Monoid m => (Key (Product * f g) -> a -> m) -> Product * f g a -> m # foldrWithKey :: (Key (Product * f g) -> a -> b -> b) -> b -> Product * f g a -> b # foldlWithKey :: (b -> Key (Product * f g) -> a -> b) -> b -> Product * f g a -> b #
(FoldableWithKey f, FoldableWithKey m) => FoldableWithKey (Compose * * f m) # |
Methods toKeyedList :: Compose * * f m a -> [(Key (Compose * * f m), a)] # foldMapWithKey :: Monoid m => (Key (Compose * * f m) -> a -> m) -> Compose * * f m a -> m # foldrWithKey :: (Key (Compose * * f m) -> a -> b -> b) -> b -> Compose * * f m a -> b # foldlWithKey :: (b -> Key (Compose * * f m) -> a -> b) -> b -> Compose * * f m a -> b #

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 #

# FoldableWithKey1

class (Foldable1 t, FoldableWithKey t) => FoldableWithKey1 t where #

Minimal complete definition

foldMapWithKey1

Methods

foldMapWithKey1 :: Semigroup m => (Key t -> a -> m) -> t a -> m #

Instances

FoldableWithKey1 Identity # |
Methods foldMapWithKey1 :: Semigroup m => (Key Identity -> a -> m) -> Identity a -> m #
FoldableWithKey1 NonEmpty # |
Methods foldMapWithKey1 :: Semigroup m => (Key NonEmpty -> a -> m) -> NonEmpty a -> m #
FoldableWithKey1 Tree # |
Methods foldMapWithKey1 :: Semigroup m => (Key Tree -> a -> m) -> Tree a -> m #
FoldableWithKey1 ((,) k) # |
Methods foldMapWithKey1 :: Semigroup m => (Key ((,) k) -> a -> m) -> (k, a) -> m #
FoldableWithKey1 f => FoldableWithKey1 (Cofree f) # |
Methods foldMapWithKey1 :: Semigroup m => (Key (Cofree f) -> a -> m) -> Cofree f a -> m #
FoldableWithKey1 f => FoldableWithKey1 (Free f) # |
Methods foldMapWithKey1 :: Semigroup m => (Key (Free f) -> a -> m) -> Free f a -> m #
FoldableWithKey1 m => FoldableWithKey1 (IdentityT * m) # |
Methods foldMapWithKey1 :: Semigroup m => (Key (IdentityT * m) -> a -> m) -> IdentityT * m a -> m #
(FoldableWithKey1 f, FoldableWithKey1 g) => FoldableWithKey1 (Product * f g) # |
Methods foldMapWithKey1 :: Semigroup m => (Key (Product * f g) -> a -> m) -> Product * f g a -> m #
(FoldableWithKey1 f, FoldableWithKey1 m) => FoldableWithKey1 (Compose * * f m) # |
Methods foldMapWithKey1 :: Semigroup m => (Key (Compose * * f m) -> a -> m) -> Compose * * f m a -> m #

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 #

# TraversableWithKey

class (Keyed t, FoldableWithKey t, Traversable t) => TraversableWithKey t where #

Minimal complete definition

traverseWithKey

Methods

traverseWithKey :: Applicative f => (Key t -> a -> f b) -> t a -> f (t b) #

mapWithKeyM :: Monad m => (Key t -> a -> m b) -> t a -> m (t b) #

Instances

TraversableWithKey [] # |
Methods traverseWithKey :: Applicative f => (Key [] -> a -> f b) -> [a] -> f [b] # mapWithKeyM :: Monad m => (Key [] -> a -> m b) -> [a] -> m [b] #
TraversableWithKey Maybe # |
Methods traverseWithKey :: Applicative f => (Key Maybe -> a -> f b) -> Maybe a -> f (Maybe b) # mapWithKeyM :: Monad m => (Key Maybe -> a -> m b) -> Maybe a -> m (Maybe b) #
TraversableWithKey Identity # |
Methods traverseWithKey :: Applicative f => (Key Identity -> a -> f b) -> Identity a -> f (Identity b) # mapWithKeyM :: Monad m => (Key Identity -> a -> m b) -> Identity a -> m (Identity b) #
TraversableWithKey NonEmpty # |
Methods traverseWithKey :: Applicative f => (Key NonEmpty -> a -> f b) -> NonEmpty a -> f (NonEmpty b) # mapWithKeyM :: Monad m => (Key NonEmpty -> a -> m b) -> NonEmpty a -> m (NonEmpty b) #
TraversableWithKey Tree # |
Methods traverseWithKey :: Applicative f => (Key Tree -> a -> f b) -> Tree a -> f (Tree b) # mapWithKeyM :: Monad m => (Key Tree -> a -> m b) -> Tree a -> m (Tree b) #
TraversableWithKey Seq # |
Methods traverseWithKey :: Applicative f => (Key Seq -> a -> f b) -> Seq a -> f (Seq b) # mapWithKeyM :: Monad m => (Key Seq -> a -> m b) -> Seq a -> m (Seq b) #
TraversableWithKey IntMap # |
Methods traverseWithKey :: Applicative f => (Key IntMap -> a -> f b) -> IntMap a -> f (IntMap b) # mapWithKeyM :: Monad m => (Key IntMap -> a -> m b) -> IntMap a -> m (IntMap b) #
TraversableWithKey ((,) k) # |
Methods traverseWithKey :: Applicative f => (Key ((,) k) -> a -> f b) -> (k, a) -> f (k, b) # mapWithKeyM :: Monad m => (Key ((,) k) -> a -> m b) -> (k, a) -> m (k, b) #
Ix i => TraversableWithKey (Array i) # |
Methods traverseWithKey :: Applicative f => (Key (Array i) -> a -> f b) -> Array i a -> f (Array i b) # mapWithKeyM :: Monad m => (Key (Array i) -> a -> m b) -> Array i a -> m (Array i b) #
TraversableWithKey (Map k) # |
Methods traverseWithKey :: Applicative f => (Key (Map k) -> a -> f b) -> Map k a -> f (Map k b) # mapWithKeyM :: Monad m => (Key (Map k) -> a -> m b) -> Map k a -> m (Map k b) #
TraversableWithKey f => TraversableWithKey (Cofree f) # |
Methods traverseWithKey :: Applicative f => (Key (Cofree f) -> a -> f b) -> Cofree f a -> f (Cofree f b) # mapWithKeyM :: Monad m => (Key (Cofree f) -> a -> m b) -> Cofree f a -> m (Cofree f b) #
TraversableWithKey f => TraversableWithKey (Free f) # |
Methods traverseWithKey :: Applicative f => (Key (Free f) -> a -> f b) -> Free f a -> f (Free f b) # mapWithKeyM :: Monad m => (Key (Free f) -> a -> m b) -> Free f a -> m (Free f b) #
TraversableWithKey (HashMap k) # |
Methods traverseWithKey :: Applicative f => (Key (HashMap k) -> a -> f b) -> HashMap k a -> f (HashMap k b) # mapWithKeyM :: Monad m => (Key (HashMap k) -> a -> m b) -> HashMap k a -> m (HashMap k b) #
TraversableWithKey m => TraversableWithKey (IdentityT * m) # |
Methods traverseWithKey :: Applicative f => (Key (IdentityT * m) -> a -> f b) -> IdentityT * m a -> f (IdentityT * m b) # mapWithKeyM :: Monad m => (Key (IdentityT * m) -> a -> m b) -> IdentityT * m a -> m (IdentityT * m b) #
(TraversableWithKey f, TraversableWithKey g) => TraversableWithKey (Product * f g) # |
Methods traverseWithKey :: Applicative f => (Key (Product * f g) -> a -> f b) -> Product * f g a -> f (Product * f g b) # mapWithKeyM :: Monad m => (Key (Product * f g) -> a -> m b) -> Product * f g a -> m (Product * f g b) #
(TraversableWithKey f, TraversableWithKey m) => TraversableWithKey (Compose * * f m) # |
Methods traverseWithKey :: Applicative f => (Key (Compose * * f m) -> a -> f b) -> Compose * * f m a -> f (Compose * * f m b) # mapWithKeyM :: Monad m => (Key (Compose * * f m) -> a -> m b) -> Compose * * f m a -> m (Compose * * f m b) #

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) #

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) #

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 #

foldMapWithKeyDefault :: (TraversableWithKey t, Monoid m) => (Key t -> a -> m) -> t a -> m #

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 #

Minimal complete definition

traverseWithKey1

Methods

traverseWithKey1 :: Apply f => (Key t -> a -> f b) -> t a -> f (t b) #

Instances

TraversableWithKey1 Identity # |
Methods traverseWithKey1 :: Apply f => (Key Identity -> a -> f b) -> Identity a -> f (Identity b) #
TraversableWithKey1 NonEmpty # |
Methods traverseWithKey1 :: Apply f => (Key NonEmpty -> a -> f b) -> NonEmpty a -> f (NonEmpty b) #
TraversableWithKey1 Tree # |
Methods traverseWithKey1 :: Apply f => (Key Tree -> a -> f b) -> Tree a -> f (Tree b) #
TraversableWithKey1 ((,) k) # |
Methods traverseWithKey1 :: Apply f => (Key ((,) k) -> a -> f b) -> (k, a) -> f (k, b) #
TraversableWithKey1 f => TraversableWithKey1 (Cofree f) # |
Methods traverseWithKey1 :: Apply f => (Key (Cofree f) -> a -> f b) -> Cofree f a -> f (Cofree f b) #
TraversableWithKey1 f => TraversableWithKey1 (Free f) # |
Methods traverseWithKey1 :: Apply f => (Key (Free f) -> a -> f b) -> Free f a -> f (Free f b) #
TraversableWithKey1 m => TraversableWithKey1 (IdentityT * m) # |
Methods traverseWithKey1 :: Apply f => (Key (IdentityT * m) -> a -> f b) -> IdentityT * m a -> f (IdentityT * m b) #
(TraversableWithKey1 f, TraversableWithKey1 g) => TraversableWithKey1 (Product * f g) # |
Methods traverseWithKey1 :: Apply f => (Key (Product * f g) -> a -> f b) -> Product * f g a -> f (Product * f g b) #
(TraversableWithKey1 f, TraversableWithKey1 m) => TraversableWithKey1 (Compose * * f m) # |
Methods traverseWithKey1 :: Apply f => (Key (Compose * * f m) -> a -> f b) -> Compose * * f m a -> f (Compose * * f m b) #

foldMapWithKey1Default :: (TraversableWithKey1 t, Semigroup m) => (Key t -> a -> m) -> t a -> m #