| Copyright | (C) 2013-16 Edward Kmett |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | Edward Kmett <ekmett@gmail.com> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Control.Lens.Combinators
Description
This lets the subset of users who vociferously disagree about the full scope and set of operators that should be exported from lens to not have to look at any operator with which they disagree.
import Control.Lens.Combinators
Synopsis
- class (Functor t, Foldable t) => Traversable (t :: Type -> Type) where
- traverse :: Applicative f => (a -> f b) -> t a -> f (t b)
- class Bifunctor (p :: Type -> Type -> Type) where
- bimap :: (a -> b) -> (c -> d) -> p a c -> p b d
- newtype Identity a = Identity {
- runIdentity :: a
- newtype Const a (b :: k) :: forall k. Type -> k -> Type = Const {
- getConst :: a
- data (a :: k) :~: (b :: k) :: forall k. k -> k -> Type where
- class Profunctor (p :: Type -> Type -> Type) where
- class Profunctor p => Lift (f :: Type -> Type) (p :: Type -> Type -> Type) where
- lift :: p a b -> p (f a) (f b)
- class Reversing t where
- reversing :: t -> t
- class (Profunctor p, Bifunctor p) => Reviewable p
- retagged :: (Profunctor p, Bifunctor p) => p a b -> p s b
- data Rightmost a
- data Leftmost a
- data Sequenced a m
- data Traversed a f
- class (Applicative f, Cotraversable f, Traversable f) => Settable f
- type Over' p f s a = Over p f s s a a
- type Over p f s t a b = p a (f b) -> s -> f t
- type LensLike' f s a = LensLike f s s a a
- type LensLike f s t a b = (a -> f b) -> s -> f t
- type Optical' p q f s a = Optical p q f s s a a
- type Optical p q f s t a b = p a (f b) -> q s (f t)
- type Optic' p f s a = Optic p f s s a a
- type Optic p f s t a b = p a (f b) -> p s (f t)
- type Simple f s a = f s s a a
- type Fold1 s a = forall f. (Functor f, Applicative f) => (a -> f a) -> s -> f s
- type Fold s a = forall f. (Functor f, Applicative f) => (a -> f a) -> s -> f s
- type Getter s a = forall f. (Functor f, Functor f) => (a -> f a) -> s -> f s
- type As a = Equality' a a
- type Equality' s a = Equality s s a a
- type Equality (s :: k1) (t :: k2) (a :: k1) (b :: k2) = forall k3 (p :: k1 -> k3 -> Type) (f :: k2 -> k3). p a (f b) -> p s (f t)
- type Prism' s a = Prism s s a a
- type Prism s t a b = forall p f. (forall a. Lift (Either a) p, Applicative f) => p a (f b) -> p s (f t)
- type AReview t b = Optic' Tagged Identity t b
- type Review t b = forall p f. (forall a. Lift (Either a) p, Bifunctor p, Settable f) => Optic' p f t b
- type Iso' s a = Iso s s a a
- type Iso s t a b = forall p f. (Profunctor p, Functor f) => p a (f b) -> p s (f t)
- type Setter' s a = Setter s s a a
- type Setter s t a b = forall f. Settable f => (a -> f b) -> s -> f t
- type Traversal' s a = Traversal s s a a
- type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t
- type Lens' s a = Lens s s a a
- type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
- type AnEquality' s a = AnEquality s s a a
- type AnEquality (s :: k1) (t :: k2) (a :: k1) (b :: k2) = Identical a (Proxy b) a (Proxy b) -> Identical a (Proxy b) s (Proxy t)
- data Identical a b s t where
- runEq :: AnEquality s t a b -> Identical s t a b
- substEq :: forall s t a b rep (r :: TYPE rep). AnEquality s t a b -> ((s ~ a, t ~ b) => r) -> r
- mapEq :: forall k1 k2 (s :: k1) (t :: k2) (a :: k1) (b :: k2) (f :: k1 -> Type). AnEquality s t a b -> f s -> f a
- fromEq :: AnEquality s t a b -> Equality b a t s
- simply :: forall p f s a rep (r :: TYPE rep). (Optic' p f s a -> r) -> Optic' p f s a -> r
- simple :: Equality' a a
- cloneEquality :: AnEquality s t a b -> Equality s t a b
- equality :: (s :~: a) -> (b :~: t) -> Equality s t a b
- equality' :: (a :~: b) -> Equality' a b
- overEquality :: AnEquality s t a b -> p a b -> p s t
- underEquality :: AnEquality s t a b -> p t s -> p b a
- fromLeibniz :: (Identical a b a b -> Identical a b s t) -> Equality s t a b
- fromLeibniz' :: ((s :~: s) -> s :~: a) -> Equality' s a
- withEquality :: forall s t a b rep (r :: TYPE rep). AnEquality s t a b -> ((s :~: a) -> (b :~: t) -> r) -> r
- type Setting' p s a = Setting p s s a a
- type Setting p s t a b = p a (Identity b) -> s -> Identity t
- type ASetter' s a = ASetter s s a a
- type ASetter s t a b = (a -> Identity b) -> s -> Identity t
- mapped :: Functor f => Setter (f a) (f b) a b
- lifted :: Monad m => Setter (m a) (m b) a b
- contramapped :: Functor f => Setter (f b) (f a) a b
- argument :: Profunctor p => Setter (p b r) (p a r) a b
- sets :: (Profunctor p, Profunctor q, Settable f) => (p a b -> q s t) -> Optical p q f s t a b
- cloneSetter :: ASetter s t a b -> Setter s t a b
- over :: ASetter s t a b -> (a -> b) -> s -> t
- set :: ASetter s t a b -> b -> s -> t
- set' :: ASetter' s a -> a -> s -> s
- assign :: MonadState s m => ASetter s s a b -> b -> m ()
- modifying :: MonadState s m => ASetter s s a b -> (a -> b) -> m ()
- scribe :: (MonadWriter t m, Monoid s) => ASetter s t a b -> b -> m ()
- passing :: MonadWriter w m => Setter w w u v -> m (a, u -> v) -> m a
- censoring :: MonadWriter w m => Setter w w u v -> (u -> v) -> m a -> m a
- locally :: MonadReader s m => ASetter s s a b -> (a -> b) -> m r -> m r
- assignA :: Arrow p => ASetter s t a b -> p s b -> p s t
- type Context' a = Context a a
- data Context a b t = Context (b -> t) a
- type ALens' s a = ALens s s a a
- type ALens s t a b = LensLike (Pretext (->) a b) s t a b
- lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b
- choosing :: Functor f => LensLike f s t a b -> LensLike f s' t' a b -> LensLike f (Either s s') (Either t t') a b
- alongside :: LensLike (AlongsideLeft f b') s t a b -> LensLike (AlongsideRight f t) s' t' a' b' -> LensLike f (s, s') (t, t') (a, a') (b, b')
- devoid :: Over p f Void Void a b
- united :: Lens' a ()
- class Field19 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field18 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field17 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field16 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field15 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field14 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field13 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field12 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field11 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field10 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field9 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field8 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field7 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field6 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field5 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field4 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field3 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field2 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Field1 s t a b | s -> a, t -> b, s b -> t, t a -> s where
- _1' :: Field1 s t a b => Lens s t a b
- _2' :: Field2 s t a b => Lens s t a b
- _3' :: Field3 s t a b => Lens s t a b
- _4' :: Field4 s t a b => Lens s t a b
- _5' :: Field5 s t a b => Lens s t a b
- _6' :: Field6 s t a b => Lens s t a b
- _7' :: Field7 s t a b => Lens s t a b
- _8' :: Field8 s t a b => Lens s t a b
- _9' :: Field9 s t a b => Lens s t a b
- _10' :: Field10 s t a b => Lens s t a b
- _11' :: Field11 s t a b => Lens s t a b
- _12' :: Field12 s t a b => Lens s t a b
- _13' :: Field13 s t a b => Lens s t a b
- _14' :: Field14 s t a b => Lens s t a b
- _15' :: Field15 s t a b => Lens s t a b
- _16' :: Field16 s t a b => Lens s t a b
- _17' :: Field17 s t a b => Lens s t a b
- _18' :: Field18 s t a b => Lens s t a b
- _19' :: Field19 s t a b => Lens s t a b
- type Bazaar1' p a = Bazaar1 p a a
- newtype Bazaar1 p a b t = Bazaar1 {
- runBazaar1 :: forall f. Applicative f => p a (f b) -> f t
- type Bazaar' p a = Bazaar p a a
- newtype Bazaar p a b t = Bazaar {
- runBazaar :: forall f. Applicative f => p a (f b) -> f t
- data Magma i t b a
- type Accessing p m s a = p a (Const m a) -> s -> Const m s
- type Getting r s a = (a -> Const r a) -> s -> Const r s
- to :: (Profunctor p, Functor f) => (s -> a) -> Optic' p f s a
- like :: (Profunctor p, Functor f, Functor f) => a -> Optic' p f s a
- view :: MonadReader s m => Getting a s a -> m a
- views :: MonadReader s m => LensLike' (Const r) s a -> (a -> r) -> m r
- use :: MonadState s m => Getting a s a -> m a
- uses :: MonadState s m => LensLike' (Const r) s a -> (a -> r) -> m r
- listening :: MonadWriter w m => Getting u w u -> m a -> m (a, u)
- listenings :: MonadWriter w m => Getting v w u -> (u -> v) -> m a -> m (a, v)
- getting :: (Profunctor p, Profunctor q, Functor f, Functor f) => Optical p q f s t a b -> Optical' p q f s a
- class (Magnified m ~ Magnified n, MonadReader b m, MonadReader a n) => Magnify m n b a | m -> b, n -> a, m a -> n, n b -> m where
- class (MonadState s m, MonadState t n) => Zoom m n s t | m -> s, n -> t, m t -> n, n s -> m where
- type family Magnified (m :: * -> *) :: * -> * -> *
- type family Zoomed (m :: * -> *) :: * -> * -> *
- unto :: (Profunctor p, Bifunctor p, Functor f) => (b -> t) -> Optic p f s t a b
- un :: (Profunctor p, Bifunctor p, Functor f) => Getting a s a -> Optic' p f a s
- re :: AReview t b -> Getter b t
- review :: MonadReader b m => AReview t b -> m t
- reviews :: MonadReader b m => AReview t b -> (t -> r) -> m r
- reuse :: MonadState b m => AReview t b -> m t
- reuses :: MonadState b m => AReview t b -> (t -> r) -> m r
- type APrism' s a = APrism s s a a
- type APrism s t a b = Market a b a (Identity b) -> Market a b s (Identity t)
- withPrism :: APrism s t a b -> ((b -> t) -> (s -> Either t a) -> r) -> r
- clonePrism :: APrism s t a b -> Prism s t a b
- prism :: (b -> t) -> (s -> Either t a) -> Prism s t a b
- prism' :: (b -> s) -> (s -> Maybe a) -> Prism s s a b
- without :: APrism s t a b -> APrism u v c d -> Prism (Either s u) (Either t v) (Either a c) (Either b d)
- aside :: APrism s t a b -> Prism (e, s) (e, t) (e, a) (e, b)
- below :: Traversable f => APrism' s a -> Prism' (f s) (f a)
- isn't :: APrism s t a b -> s -> Bool
- matching :: APrism s t a b -> s -> Either t a
- _Left :: Prism (Either a c) (Either b c) a b
- _Right :: Prism (Either c a) (Either c b) a b
- _Just :: Prism (Maybe a) (Maybe b) a b
- _Nothing :: Prism' (Maybe a) ()
- _Void :: Prism s s a Void
- only :: Eq a => a -> Prism' a ()
- nearly :: a -> (a -> Bool) -> Prism' a ()
- _Show :: (Read a, Show a) => Prism' String a
- folding :: Foldable f => (s -> f a) -> Fold s a
- foldring :: (Functor f, Applicative f) => ((a -> f a -> f a) -> f a -> s -> f a) -> LensLike f s t a b
- repeated :: Applicative f => LensLike' f a a
- replicated :: Int -> Fold a a
- cycled :: Applicative f => LensLike f s t a b -> LensLike f s t a b
- unfolded :: (b -> Maybe (a, b)) -> Fold b a
- iterated :: Applicative f => (a -> a) -> LensLike' f a a
- filtered :: (forall a. Lift (Either a) p, Applicative f) => (a -> Bool) -> Optic' p f a a
- foldMapOf :: Getting r s a -> (a -> r) -> s -> r
- foldOf :: Getting a s a -> s -> a
- foldrOf :: Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r
- foldlOf :: Getting (Dual (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
- toListOf :: Getting (Endo [a]) s a -> s -> [a]
- toNonEmptyOf :: Getting (NonEmptyDList a) s a -> s -> NonEmpty a
- andOf :: Getting All s Bool -> s -> Bool
- orOf :: Getting Any s Bool -> s -> Bool
- anyOf :: Getting Any s a -> (a -> Bool) -> s -> Bool
- allOf :: Getting All s a -> (a -> Bool) -> s -> Bool
- noneOf :: Getting Any s a -> (a -> Bool) -> s -> Bool
- productOf :: Num a => Getting (Endo (Endo a)) s a -> s -> a
- sumOf :: Num a => Getting (Endo (Endo a)) s a -> s -> a
- traverseOf_ :: Functor f => Getting (Traversed r f) s a -> (a -> f r) -> s -> f ()
- forOf_ :: Functor f => Getting (Traversed r f) s a -> s -> (a -> f r) -> f ()
- sequenceAOf_ :: Functor f => Getting (Traversed a f) s (f a) -> s -> f ()
- traverse1Of_ :: Functor f => Getting (TraversedF r f) s a -> (a -> f r) -> s -> f ()
- for1Of_ :: Functor f => Getting (TraversedF r f) s a -> s -> (a -> f r) -> f ()
- sequence1Of_ :: Functor f => Getting (TraversedF a f) s (f a) -> s -> f ()
- mapMOf_ :: Monad m => Getting (Sequenced r m) s a -> (a -> m r) -> s -> m ()
- forMOf_ :: Monad m => Getting (Sequenced r m) s a -> s -> (a -> m r) -> m ()
- sequenceOf_ :: Monad m => Getting (Sequenced a m) s (m a) -> s -> m ()
- asumOf :: Alternative f => Getting (Endo (f a)) s (f a) -> s -> f a
- msumOf :: MonadPlus m => Getting (Endo (m a)) s (m a) -> s -> m a
- elemOf :: Eq a => Getting Any s a -> a -> s -> Bool
- notElemOf :: Eq a => Getting All s a -> a -> s -> Bool
- concatMapOf :: Getting [r] s a -> (a -> [r]) -> s -> [r]
- concatOf :: Getting [r] s [r] -> s -> [r]
- lengthOf :: Getting (Endo (Endo Int)) s a -> s -> Int
- firstOf :: Getting (Leftmost a) s a -> s -> Maybe a
- first1Of :: Getting (First a) s a -> s -> a
- lastOf :: Getting (Rightmost a) s a -> s -> Maybe a
- last1Of :: Getting (Last a) s a -> s -> a
- nullOf :: Getting All s a -> s -> Bool
- notNullOf :: Getting Any s a -> s -> Bool
- maximumOf :: Ord a => Getting (Endo (Endo (Maybe a))) s a -> s -> Maybe a
- maximum1Of :: Ord a => Getting (Max a) s a -> s -> a
- minimumOf :: Ord a => Getting (Endo (Endo (Maybe a))) s a -> s -> Maybe a
- minimum1Of :: Ord a => Getting (Min a) s a -> s -> a
- maximumByOf :: Getting (Endo (Endo (Maybe a))) s a -> (a -> a -> Ordering) -> s -> Maybe a
- minimumByOf :: Getting (Endo (Endo (Maybe a))) s a -> (a -> a -> Ordering) -> s -> Maybe a
- findOf :: Getting (Endo (Maybe a)) s a -> (a -> Bool) -> s -> Maybe a
- findMOf :: Monad m => Getting (Endo (m (Maybe a))) s a -> (a -> m Bool) -> s -> m (Maybe a)
- lookupOf :: Eq k => Getting (Endo (Maybe v)) s (k, v) -> k -> s -> Maybe v
- foldr1Of :: Getting (Endo1 a) s a -> (a -> a -> a) -> s -> a
- foldl1Of :: Getting (Dual (Endo1 a)) s a -> (a -> a -> a) -> s -> a
- foldrOf' :: Getting (Dual (Endo (Endo r))) s a -> (a -> r -> r) -> r -> s -> r
- foldlOf' :: Getting (Endo (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
- foldrMOf :: Monad m => Getting (Dual (Endo (r -> m r))) s a -> (a -> r -> m r) -> r -> s -> m r
- foldlMOf :: Monad m => Getting (Endo (r -> m r)) s a -> (r -> a -> m r) -> r -> s -> m r
- has :: Getting Any s a -> s -> Bool
- hasn't :: Getting All s a -> s -> Bool
- pre :: Getting (First a) s a -> Getter s (Maybe a)
- preview :: MonadReader s m => Getting (First a) s a -> m (Maybe a)
- previews :: MonadReader s m => Getting (First r) s a -> (a -> r) -> m (Maybe r)
- preuse :: MonadState s m => Getting (First a) s a -> m (Maybe a)
- preuses :: MonadState s m => Getting (First r) s a -> (a -> r) -> m (Maybe r)
- backwards :: (Profunctor p, Profunctor q) => Optical p q (Backwards f) s t a b -> Optical p q f s t a b
- type ATraversal1' s a = ATraversal1 s s a a
- type ATraversal1 s t a b = LensLike (Bazaar1 (->) a b) s t a b
- type ATraversal' s a = ATraversal s s a a
- type ATraversal s t a b = LensLike (Bazaar (->) a b) s t a b
- traverseOf :: LensLike f s t a b -> (a -> f b) -> s -> f t
- forOf :: LensLike f s t a b -> s -> (a -> f b) -> f t
- sequenceAOf :: LensLike f s t (f b) b -> s -> f t
- mapMOf :: LensLike (WrappedMonad m) s t a b -> (a -> m b) -> s -> m t
- forMOf :: LensLike (WrappedMonad m) s t a b -> s -> (a -> m b) -> m t
- sequenceOf :: LensLike (WrappedMonad m) s t (m b) b -> s -> m t
- transposeOf :: LensLike ZipList s t [a] a -> s -> [t]
- mapAccumROf :: LensLike (Backwards (State acc)) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
- mapAccumLOf :: LensLike (State acc) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
- scanr1Of :: LensLike (Backwards (State (Maybe a))) s t a a -> (a -> a -> a) -> s -> t
- scanl1Of :: LensLike (State (Maybe a)) s t a a -> (a -> a -> a) -> s -> t
- both :: Bitraversable r => Traversal (r a a) (r b b) a b
- ignored :: Applicative f => pafb -> s -> f s
- failover :: Alternative m => LensLike ((,) Any) s t a b -> (a -> b) -> s -> m t
- type ReifiedPrism' s a = ReifiedPrism s s a a
- newtype ReifiedPrism s t a b = Prism {}
- type ReifiedIso' s a = ReifiedIso s s a a
- newtype ReifiedIso s t a b = Iso {}
- type ReifiedSetter' s a = ReifiedSetter s s a a
- newtype ReifiedSetter s t a b = Setter {}
- newtype ReifiedFold s a = Fold {}
- newtype ReifiedGetter s a = Getter {}
- type ReifiedTraversal' s a = ReifiedTraversal s s a a
- newtype ReifiedTraversal s t a b = Traversal {
- runTraversal :: Traversal s t a b
- type ReifiedLens' s a = ReifiedLens s s a a
- newtype ReifiedLens s t a b = Lens {}
- class GPlated1 f g
- class GPlated a g
- class Plated a where
- plate :: Traversal' a a
- children :: Plated a => a -> [a]
- rewrite :: Plated a => (a -> Maybe a) -> a -> a
- rewriteOf :: ASetter a b a b -> (b -> Maybe a) -> a -> b
- rewriteOn :: Plated a => ASetter s t a a -> (a -> Maybe a) -> s -> t
- rewriteOnOf :: ASetter s t a b -> ASetter a b a b -> (b -> Maybe a) -> s -> t
- rewriteM :: (Monad m, Plated a) => (a -> m (Maybe a)) -> a -> m a
- rewriteMOf :: Monad m => LensLike (WrappedMonad m) a b a b -> (b -> m (Maybe a)) -> a -> m b
- rewriteMOn :: (Monad m, Plated a) => LensLike (WrappedMonad m) s t a a -> (a -> m (Maybe a)) -> s -> m t
- rewriteMOnOf :: Monad m => LensLike (WrappedMonad m) s t a b -> LensLike (WrappedMonad m) a b a b -> (b -> m (Maybe a)) -> s -> m t
- universe :: Plated a => a -> [a]
- universeOf :: Getting [a] a a -> a -> [a]
- universeOn :: Plated a => Getting [a] s a -> s -> [a]
- universeOnOf :: Getting [a] s a -> Getting [a] a a -> s -> [a]
- cosmos :: Plated a => Fold a a
- cosmosOf :: (Applicative f, Functor f) => LensLike' f a a -> LensLike' f a a
- cosmosOn :: (Applicative f, Functor f, Plated a) => LensLike' f s a -> LensLike' f s a
- cosmosOnOf :: (Applicative f, Functor f) => LensLike' f s a -> LensLike' f a a -> LensLike' f s a
- transform :: Plated a => (a -> a) -> a -> a
- transformOn :: Plated a => ASetter s t a a -> (a -> a) -> s -> t
- transformOf :: ASetter a b a b -> (b -> b) -> a -> b
- transformOnOf :: ASetter s t a b -> ASetter a b a b -> (b -> b) -> s -> t
- transformM :: (Monad m, Plated a) => (a -> m a) -> a -> m a
- transformMOn :: (Monad m, Plated a) => LensLike (WrappedMonad m) s t a a -> (a -> m a) -> s -> m t
- transformMOf :: Monad m => LensLike (WrappedMonad m) a b a b -> (b -> m b) -> a -> m b
- transformMOnOf :: Monad m => LensLike (WrappedMonad m) s t a b -> LensLike (WrappedMonad m) a b a b -> (b -> m b) -> s -> m t
- paraOf :: Getting (Endo [a]) a a -> (a -> [r] -> r) -> a -> r
- para :: Plated a => (a -> [r] -> r) -> a -> r
- composOpFold :: Plated a => b -> (b -> b -> b) -> (a -> b) -> a -> b
- gplate :: (Generic a, GPlated a (Rep a)) => Traversal' a a
- gplate1 :: (Generic1 f, GPlated1 f (Rep1 f)) => Traversal' (f a) (f a)
- class Strict lazy strict | lazy -> strict, strict -> lazy where
- class Bifunctor p => Swapped p where
- type AnIso' s a = AnIso s s a a
- type AnIso s t a b = Exchange a b a (Identity b) -> Exchange a b s (Identity t)
- pattern List :: forall l. IsList l => [Item l] -> l
- pattern Reversed :: forall t. Reversing t => t -> t
- pattern Swapped :: forall (p :: Type -> Type -> Type) c d. Swapped p => p d c -> p c d
- pattern Lazy :: forall t s. Strict t s => t -> s
- pattern Strict :: forall s t. Strict s t => t -> s
- iso :: (s -> a) -> (b -> t) -> Iso s t a b
- from :: AnIso s t a b -> Iso b a t s
- withIso :: forall s t a b rep (r :: TYPE rep). AnIso s t a b -> ((s -> a) -> (b -> t) -> r) -> r
- cloneIso :: AnIso s t a b -> Iso s t a b
- au :: Functor f => AnIso s t a b -> ((b -> t) -> f s) -> f a
- auf :: (Functor f, Functor g) => AnIso s t a b -> (f t -> g s) -> f b -> g a
- under :: AnIso s t a b -> (t -> s) -> b -> a
- enum :: Enum a => Iso' Int a
- mapping :: (Functor f, Functor g) => AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
- non :: Eq a => a -> Iso' (Maybe a) a
- non' :: APrism' a () -> Iso' (Maybe a) a
- anon :: a -> (a -> Bool) -> Iso' (Maybe a) a
- curried :: Iso ((a, b) -> c) ((d, e) -> f) (a -> b -> c) (d -> e -> f)
- uncurried :: Iso (a -> b -> c) (d -> e -> f) ((a, b) -> c) ((d, e) -> f)
- flipped :: Iso (a -> b -> c) (a' -> b' -> c') (b -> a -> c) (b' -> a' -> c')
- lazy :: Strict lazy strict => Iso' strict lazy
- reversed :: Reversing a => Iso' a a
- involuted :: (a -> a) -> Iso' a a
- contramapping :: Functor f => AnIso s t a b -> Iso (f a) (f b) (f s) (f t)
- dimapping :: (Profunctor p, Profunctor q) => AnIso s t a b -> AnIso s' t' a' b' -> Iso (p a s') (q b t') (p s a') (q t b')
- lmapping :: (Profunctor p, Profunctor q) => AnIso s t a b -> Iso (p a x) (q b y) (p s x) (q t y)
- rmapping :: (Profunctor p, Profunctor q) => AnIso s t a b -> Iso (p x s) (q y t) (p x a) (q y b)
- bimapping :: (Bifunctor f, Bifunctor g) => AnIso s t a b -> AnIso s' t' a' b' -> Iso (f s s') (g t t') (f a a') (g b b')
- firsting :: (Bifunctor f, Bifunctor g) => AnIso s t a b -> Iso (f s x) (g t y) (f a x) (g b y)
- seconding :: (Bifunctor f, Bifunctor g) => AnIso s t a b -> Iso (f x s) (g y t) (f x a) (g y b)
- coerced :: forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
- class (Rewrapped s t, Rewrapped t s) => Rewrapping s t
- class Wrapped s => Rewrapped (s :: *) (t :: *)
- class Wrapped s where
- _GWrapped' :: (Generic s, D1 d (C1 c (S1 s' (Rec0 a))) ~ Rep s, Unwrapped s ~ GUnwrapped (Rep s)) => Iso' s (Unwrapped s)
- _Unwrapped' :: Wrapped s => Iso' (Unwrapped s) s
- _Wrapped :: Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t)
- _Unwrapped :: Rewrapping s t => Iso (Unwrapped t) (Unwrapped s) t s
- op :: Wrapped s => (Unwrapped s -> s) -> s -> Unwrapped s
- _Wrapping' :: Wrapped s => (Unwrapped s -> s) -> Iso' s (Unwrapped s)
- _Unwrapping' :: Wrapped s => (Unwrapped s -> s) -> Iso' (Unwrapped s) s
- _Wrapping :: Rewrapping s t => (Unwrapped s -> s) -> Iso s t (Unwrapped s) (Unwrapped t)
- _Unwrapping :: Rewrapping s t => (Unwrapped s -> s) -> Iso (Unwrapped t) (Unwrapped s) t s
- class Snoc s t a b | s -> a, t -> b, s b -> t, t a -> s where
- class Cons s t a b | s -> a, t -> b, s b -> t, t a -> s where
- cons :: Cons s s a a => a -> s -> s
- uncons :: Cons s s a a => s -> Maybe (a, s)
- _head :: Cons s s a a => Traversal' s a
- _tail :: Cons s s a a => Traversal' s s
- _init :: Snoc s s a a => Traversal' s s
- _last :: Snoc s s a a => Traversal' s a
- snoc :: Snoc s s a a => s -> a -> s
- unsnoc :: Snoc s s a a => s -> Maybe (s, a)
- class AsEmpty a where
- pattern Empty :: forall s. AsEmpty s => s
Documentation
class (Functor t, Foldable t) => Traversable (t :: Type -> Type) where #
Functors representing data structures that can be traversed from left to right.
A definition of traverse must satisfy the following laws:
- naturality
t .for every applicative transformationtraversef =traverse(t . f)t- identity
traverseIdentity = Identity- composition
traverse(Compose .fmapg . f) = Compose .fmap(traverseg) .traversef
A definition of sequenceA must satisfy the following laws:
- naturality
t .for every applicative transformationsequenceA=sequenceA.fmaptt- identity
sequenceA.fmapIdentity = Identity- composition
sequenceA.fmapCompose = Compose .fmapsequenceA.sequenceA
where an applicative transformation is a function
t :: (Applicative f, Applicative g) => f a -> g a
preserving the Applicative operations, i.e.
and the identity functor Identity and composition of functors Compose
are defined as
newtype Identity a = Identity a
instance Functor Identity where
fmap f (Identity x) = Identity (f x)
instance Applicative Identity where
pure x = Identity x
Identity f <*> Identity x = Identity (f x)
newtype Compose f g a = Compose (f (g a))
instance (Functor f, Functor g) => Functor (Compose f g) where
fmap f (Compose x) = Compose (fmap (fmap f) x)
instance (Applicative f, Applicative g) => Applicative (Compose f g) where
pure x = Compose (pure (pure x))
Compose f <*> Compose x = Compose ((<*>) <$> f <*> x)(The naturality law is implied by parametricity.)
Instances are similar to Functor, e.g. given a data type
data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
a suitable instance would be
instance Traversable Tree where traverse f Empty = pure Empty traverse f (Leaf x) = Leaf <$> f x traverse f (Node l k r) = Node <$> traverse f l <*> f k <*> traverse f r
This is suitable even for abstract types, as the laws for <*>
imply a form of associativity.
The superclass instances should satisfy the following:
- In the
Functorinstance,fmapshould be equivalent to traversal with the identity applicative functor (fmapDefault). - In the
Foldableinstance,foldMapshould be equivalent to traversal with a constant applicative functor (foldMapDefault).
Methods
traverse :: Applicative f => (a -> f b) -> t a -> f (t b) #
Map each element of a structure to an action, evaluate these actions
from left to right, and collect the results. For a version that ignores
the results see traverse_.
Instances
class Bifunctor (p :: Type -> Type -> Type) where #
A bifunctor is a type constructor that takes
two type arguments and is a functor in both arguments. That
is, unlike with Functor, a type constructor such as Either
does not need to be partially applied for a Bifunctor
instance, and the methods in this class permit mapping
functions over the Left value or the Right value,
or both at the same time.
Formally, the class Bifunctor represents a bifunctor
from Hask -> Hask.
Intuitively it is a bifunctor where both the first and second arguments are covariant.
You can define a Bifunctor by either defining bimap or by
defining both first and second.
If you supply bimap, you should ensure that:
bimapidid≡id
If you supply first and second, ensure:
firstid≡idsecondid≡id
If you supply both, you should also ensure:
bimapf g ≡firstf.secondg
These ensure by parametricity:
bimap(f.g) (h.i) ≡bimapf h.bimapg ifirst(f.g) ≡firstf.firstgsecond(f.g) ≡secondf.secondg
Since: base-4.8.0.0
Methods
Instances
| Bifunctor Either | Since: base-4.8.0.0 |
| Bifunctor (,) | Since: base-4.8.0.0 |
| Bifunctor Arg | Since: base-4.9.0.0 |
| Bifunctor ((,,) x1) | Since: base-4.8.0.0 |
| Bifunctor (Const :: Type -> Type -> Type) | Since: base-4.8.0.0 |
| Bifunctor (Tagged :: Type -> Type -> Type) | |
| Bifunctor (Constant :: Type -> Type -> Type) | |
| Functor f => Bifunctor (AlongsideRight f) Source # | |
Defined in Control.Lens.Internal.Getter Methods bimap :: (a -> b) -> (c -> d) -> AlongsideRight f a c -> AlongsideRight f b d # first :: (a -> b) -> AlongsideRight f a c -> AlongsideRight f b c # second :: (b -> c) -> AlongsideRight f a b -> AlongsideRight f a c # | |
| Functor f => Bifunctor (AlongsideLeft f) Source # | |
Defined in Control.Lens.Internal.Getter Methods bimap :: (a -> b) -> (c -> d) -> AlongsideLeft f a c -> AlongsideLeft f b d # first :: (a -> b) -> AlongsideLeft f a c -> AlongsideLeft f b c # second :: (b -> c) -> AlongsideLeft f a b -> AlongsideLeft f a c # | |
| Bifunctor (K1 i :: Type -> Type -> Type) | Since: base-4.9.0.0 |
| Bifunctor ((,,,) x1 x2) | Since: base-4.8.0.0 |
| Bifunctor ((,,,,) x1 x2 x3) | Since: base-4.8.0.0 |
| Bifunctor k => Bifunctor (Dual k) | |
| Bifunctor ((,,,,,) x1 x2 x3 x4) | Since: base-4.8.0.0 |
| Bifunctor ((,,,,,,) x1 x2 x3 x4 x5) | Since: base-4.8.0.0 |
| (Functor f, Bifunctor s) => Bifunctor (Tannen f s) | |
| (Bifunctor s, Functor f, Functor g) => Bifunctor (Biff s f g) | |
Identity functor and monad. (a non-strict monad)
Since: base-4.8.0.0
Constructors
| Identity | |
Fields
| |
Instances
newtype Const a (b :: k) :: forall k. Type -> k -> Type #
The Const functor.
Instances
| Generic1 (Const a :: k -> Type) | |
| Bitraversable (Const :: Type -> Type -> Type) | Since: base-4.10.0.0 |
Defined in Data.Bitraversable Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Const a b -> f (Const c d) # | |
| Bifoldable (Const :: Type -> Type -> Type) | Since: base-4.10.0.0 |
| Bifunctor (Const :: Type -> Type -> Type) | Since: base-4.8.0.0 |
| Eq2 (Const :: Type -> Type -> Type) | Since: base-4.9.0.0 |
| Ord2 (Const :: Type -> Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
| Read2 (Const :: Type -> Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes Methods liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Const a b) # liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Const a b] # liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Const a b) # liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Const a b] # | |
| Show2 (Const :: Type -> Type -> Type) | Since: base-4.9.0.0 |
| Functor (Const m :: Type -> Type) | Since: base-2.1 |
| Monoid m => Applicative (Const m :: Type -> Type) | Since: base-2.0.1 |
| Foldable (Const m :: Type -> Type) | Since: base-4.7.0.0 |
Defined in Data.Functor.Const Methods fold :: Monoid m0 => Const m m0 -> m0 # foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 # foldr :: (a -> b -> b) -> b -> Const m a -> b # foldr' :: (a -> b -> b) -> b -> Const m a -> b # foldl :: (b -> a -> b) -> b -> Const m a -> b # foldl' :: (b -> a -> b) -> b -> Const m a -> b # foldr1 :: (a -> a -> a) -> Const m a -> a # foldl1 :: (a -> a -> a) -> Const m a -> a # elem :: Eq a => a -> Const m a -> Bool # maximum :: Ord a => Const m a -> a # minimum :: Ord a => Const m a -> a # | |
| Traversable (Const m :: Type -> Type) | Since: base-4.7.0.0 |
| Eq a => Eq1 (Const a :: Type -> Type) | Since: base-4.9.0.0 |
| Ord a => Ord1 (Const a :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
| Read a => Read1 (Const a :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes Methods liftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (Const a a0) # liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [Const a a0] # liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (Const a a0) # liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [Const a a0] # | |
| Show a => Show1 (Const a :: Type -> Type) | Since: base-4.9.0.0 |
| Functor (Const a :: Type -> Type) | |
| Bounded a => Bounded (Const a b) | Since: base-4.9.0.0 |
| Enum a => Enum (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods succ :: Const a b -> Const a b # pred :: Const a b -> Const a b # fromEnum :: Const a b -> Int # enumFrom :: Const a b -> [Const a b] # enumFromThen :: Const a b -> Const a b -> [Const a b] # enumFromTo :: Const a b -> Const a b -> [Const a b] # enumFromThenTo :: Const a b -> Const a b -> Const a b -> [Const a b] # | |
| Eq a => Eq (Const a b) | Since: base-4.9.0.0 |
| Floating a => Floating (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods exp :: Const a b -> Const a b # log :: Const a b -> Const a b # sqrt :: Const a b -> Const a b # (**) :: Const a b -> Const a b -> Const a b # logBase :: Const a b -> Const a b -> Const a b # sin :: Const a b -> Const a b # cos :: Const a b -> Const a b # tan :: Const a b -> Const a b # asin :: Const a b -> Const a b # acos :: Const a b -> Const a b # atan :: Const a b -> Const a b # sinh :: Const a b -> Const a b # cosh :: Const a b -> Const a b # tanh :: Const a b -> Const a b # asinh :: Const a b -> Const a b # acosh :: Const a b -> Const a b # atanh :: Const a b -> Const a b # log1p :: Const a b -> Const a b # expm1 :: Const a b -> Const a b # | |
| Fractional a => Fractional (Const a b) | Since: base-4.9.0.0 |
| Integral a => Integral (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods quot :: Const a b -> Const a b -> Const a b # rem :: Const a b -> Const a b -> Const a b # div :: Const a b -> Const a b -> Const a b # mod :: Const a b -> Const a b -> Const a b # quotRem :: Const a b -> Const a b -> (Const a b, Const a b) # divMod :: Const a b -> Const a b -> (Const a b, Const a b) # | |
| (Typeable k, Data a, Typeable b) => Data (Const a b) | Since: base-4.10.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Const a b -> c (Const a b) # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Const a b) # toConstr :: Const a b -> Constr # dataTypeOf :: Const a b -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Const a b)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Const a b)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> Const a b -> Const a b # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Const a b -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Const a b -> r # gmapQ :: (forall d. Data d => d -> u) -> Const a b -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Const a b -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Const a b -> m (Const a b) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Const a b -> m (Const a b) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Const a b -> m (Const a b) # | |
| Num a => Num (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const | |
| Ord a => Ord (Const a b) | Since: base-4.9.0.0 |
| Read a => Read (Const a b) | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
| Real a => Real (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods toRational :: Const a b -> Rational # | |
| RealFloat a => RealFloat (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods floatRadix :: Const a b -> Integer # floatDigits :: Const a b -> Int # floatRange :: Const a b -> (Int, Int) # decodeFloat :: Const a b -> (Integer, Int) # encodeFloat :: Integer -> Int -> Const a b # exponent :: Const a b -> Int # significand :: Const a b -> Const a b # scaleFloat :: Int -> Const a b -> Const a b # isInfinite :: Const a b -> Bool # isDenormalized :: Const a b -> Bool # isNegativeZero :: Const a b -> Bool # | |
| RealFrac a => RealFrac (Const a b) | Since: base-4.9.0.0 |
| Show a => Show (Const a b) | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
| Ix a => Ix (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods range :: (Const a b, Const a b) -> [Const a b] # index :: (Const a b, Const a b) -> Const a b -> Int # unsafeIndex :: (Const a b, Const a b) -> Const a b -> Int inRange :: (Const a b, Const a b) -> Const a b -> Bool # rangeSize :: (Const a b, Const a b) -> Int # unsafeRangeSize :: (Const a b, Const a b) -> Int | |
| Generic (Const a b) | |
| Semigroup a => Semigroup (Const a b) | Since: base-4.9.0.0 |
| Monoid a => Monoid (Const a b) | Since: base-4.9.0.0 |
| Storable a => Storable (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const | |
| Bits a => Bits (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods (.&.) :: Const a b -> Const a b -> Const a b # (.|.) :: Const a b -> Const a b -> Const a b # xor :: Const a b -> Const a b -> Const a b # complement :: Const a b -> Const a b # shift :: Const a b -> Int -> Const a b # rotate :: Const a b -> Int -> Const a b # setBit :: Const a b -> Int -> Const a b # clearBit :: Const a b -> Int -> Const a b # complementBit :: Const a b -> Int -> Const a b # testBit :: Const a b -> Int -> Bool # bitSizeMaybe :: Const a b -> Maybe Int # isSigned :: Const a b -> Bool # shiftL :: Const a b -> Int -> Const a b # unsafeShiftL :: Const a b -> Int -> Const a b # shiftR :: Const a b -> Int -> Const a b # unsafeShiftR :: Const a b -> Int -> Const a b # rotateL :: Const a b -> Int -> Const a b # | |
| FiniteBits a => FiniteBits (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods finiteBitSize :: Const a b -> Int # countLeadingZeros :: Const a b -> Int # countTrailingZeros :: Const a b -> Int # | |
| Prim a => Prim (Const a b) | Since: primitive-0.6.5.0 |
Defined in Data.Primitive.Types Methods sizeOf# :: Const a b -> Int# # alignment# :: Const a b -> Int# # indexByteArray# :: ByteArray# -> Int# -> Const a b # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#State# s, Const a b#) # writeByteArray# :: MutableByteArray# s -> Int# -> Const a b -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Const a b -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Const a b # readOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Const a b#) # writeOffAddr# :: Addr# -> Int# -> Const a b -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Const a b -> State# s -> State# s # | |
| Wrapped (Const a x) Source # | |
| t ~ Const a' x' => Rewrapped (Const a x) t Source # | |
Defined in Control.Lens.Wrapped | |
| type Rep1 (Const a :: k -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const | |
| type Rep (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const | |
| type Unwrapped (Const a x) Source # | |
Defined in Control.Lens.Wrapped | |
data (a :: k) :~: (b :: k) :: forall k. k -> k -> Type where infix 4 #
Propositional equality. If a :~: b is inhabited by some terminating
value, then the type a is the same as the type b. To use this equality
in practice, pattern-match on the a :~: b to get out the Refl constructor;
in the body of the pattern-match, the compiler knows that a ~ b.
Since: base-4.7.0.0
Instances
| Category ((:~:) :: k -> k -> Type) | Since: base-4.7.0.0 |
| TestEquality ((:~:) a :: k -> Type) | Since: base-4.7.0.0 |
Defined in Data.Type.Equality | |
| a ~ b => Bounded (a :~: b) | Since: base-4.7.0.0 |
| a ~ b => Enum (a :~: b) | Since: base-4.7.0.0 |
Defined in Data.Type.Equality Methods succ :: (a :~: b) -> a :~: b # pred :: (a :~: b) -> a :~: b # fromEnum :: (a :~: b) -> Int # enumFrom :: (a :~: b) -> [a :~: b] # enumFromThen :: (a :~: b) -> (a :~: b) -> [a :~: b] # enumFromTo :: (a :~: b) -> (a :~: b) -> [a :~: b] # enumFromThenTo :: (a :~: b) -> (a :~: b) -> (a :~: b) -> [a :~: b] # | |
| Eq (a :~: b) | Since: base-4.7.0.0 |
| (a ~ b, Data a) => Data (a :~: b) | Since: base-4.7.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> (a :~: b) -> c (a :~: b) # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (a :~: b) # toConstr :: (a :~: b) -> Constr # dataTypeOf :: (a :~: b) -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (a :~: b)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (a :~: b)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> (a :~: b) -> a :~: b # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> (a :~: b) -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> (a :~: b) -> r # gmapQ :: (forall d. Data d => d -> u) -> (a :~: b) -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> (a :~: b) -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> (a :~: b) -> m (a :~: b) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> (a :~: b) -> m (a :~: b) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> (a :~: b) -> m (a :~: b) # | |
| Ord (a :~: b) | Since: base-4.7.0.0 |
Defined in Data.Type.Equality | |
| a ~ b => Read (a :~: b) | Since: base-4.7.0.0 |
| Show (a :~: b) | Since: base-4.7.0.0 |
class Profunctor (p :: Type -> Type -> Type) where #
Minimal complete definition
Nothing
Instances
| Profunctor ReifiedFold Source # | |
Defined in Control.Lens.Reified Methods dimap :: (a -> b) -> (c -> d) -> ReifiedFold b c -> ReifiedFold a d # lmap :: (a -> b) -> ReifiedFold b c -> ReifiedFold a c # rmap :: (b -> c) -> ReifiedFold a b -> ReifiedFold a c # | |
| Profunctor ReifiedGetter Source # | |
Defined in Control.Lens.Reified Methods dimap :: (a -> b) -> (c -> d) -> ReifiedGetter b c -> ReifiedGetter a d # lmap :: (a -> b) -> ReifiedGetter b c -> ReifiedGetter a c # rmap :: (b -> c) -> ReifiedGetter a b -> ReifiedGetter a c # | |
| Functor f => Profunctor (Kleisli f) | |
| Profunctor (Tagged :: Type -> Type -> Type) | |
| Profunctor ((->) :: Type -> Type -> Type) | |
| Functor f => Profunctor (Cokleisli f) | |
| Profunctor (Exchange a b) Source # | |
| Profunctor (Market a b) Source # | |
| (Functor f, Profunctor p) => Profunctor (Tannen f p) | |
| (Profunctor p, Functor f, Functor g) => Profunctor (Biff p f g) | |
class Profunctor p => Lift (f :: Type -> Type) (p :: Type -> Type -> Type) where #
Instances
class Reversing t where Source #
This class provides a generalized notion of list reversal extended to other containers.
class (Profunctor p, Bifunctor p) => Reviewable p Source #
This class is provided mostly for backwards compatibility with lens 3.8, but it can also shorten type signatures.
Instances
| (Profunctor p, Bifunctor p) => Reviewable p Source # | |
Defined in Control.Lens.Internal.Review | |
retagged :: (Profunctor p, Bifunctor p) => p a b -> p s b Source #
This is a profunctor used internally to implement Review
It plays a role similar to that of Accessor
or Const do for Control.Lens.Getter
Used internally by mapM_ and the like.
The argument a of the result should not be used!
See 4.16 Changelog entry for the explanation of "why not Apply f =>"?
Used internally by traverseOf_ and the like.
The argument a of the result should not be used!
class (Applicative f, Cotraversable f, Traversable f) => Settable f Source #
Minimal complete definition
Instances
| Settable Identity Source # | So you can pass our |
Defined in Control.Lens.Internal.Setter Methods untainted :: Identity a -> a Source # untaintedDot :: Profunctor p => p a (Identity b) -> p a b Source # taintedDot :: Profunctor p => p a b -> p a (Identity b) Source # | |
| Settable f => Settable (Backwards f) Source # | |
Defined in Control.Lens.Internal.Setter Methods untainted :: Backwards f a -> a Source # untaintedDot :: Profunctor p => p a (Backwards f b) -> p a b Source # taintedDot :: Profunctor p => p a b -> p a (Backwards f b) Source # | |
| (Settable f, Settable g) => Settable (Compose f g) Source # | |
Defined in Control.Lens.Internal.Setter Methods untainted :: Compose f g a -> a Source # untaintedDot :: Profunctor p => p a (Compose f g b) -> p a b Source # taintedDot :: Profunctor p => p a b -> p a (Compose f g b) Source # | |
type Over p f s t a b = p a (f b) -> s -> f t Source #
This is a convenient alias for use when you need to consume either indexed or non-indexed lens-likes based on context.
type LensLike f s t a b = (a -> f b) -> s -> f t Source #
Many combinators that accept a Lens can also accept a
Traversal in limited situations.
They do so by specializing the type of Functor that they require of the
caller.
If a function accepts a for some LensLike f s t a bFunctor f,
then they may be passed a Lens.
Further, if f is an Applicative, they may also be passed a
Traversal.
type Optic p f s t a b = p a (f b) -> p s (f t) Source #
A valid Optic l should satisfy the laws:
lpure≡purel (Procomposef g) =Procompose(l f) (l g)
This gives rise to the laws for Equality, Iso, Prism, Lens,
Traversal, Traversal1, Setter, Fold, Fold1, and Getter as well
along with their index-preserving variants.
typeLensLikef s t a b =Optic(->) f s t a b
type Simple f s a = f s s a a Source #
A Simple Lens, Simple Traversal, ... can
be used instead of a Lens,Traversal, ...
whenever the type variables don't change upon setting a value.
_imagPart::SimpleLens(Complexa) atraversed::Simple(IndexedTraversalInt) [a] a
Note: To use this alias in your own code with or
LensLike fSetter, you may have to turn on LiberalTypeSynonyms.
This is commonly abbreviated as a "prime" marker, e.g. Lens' = Simple Lens.
type Fold1 s a = forall f. (Functor f, Applicative f) => (a -> f a) -> s -> f s Source #
A relevant Fold (aka Fold1) has one or more targets.
type Fold s a = forall f. (Functor f, Applicative f) => (a -> f a) -> s -> f s Source #
A Fold describes how to retrieve multiple values in a way that can be composed
with other LensLike constructions.
A provides a structure with operations very similar to those of the Fold s aFoldable
typeclass, see foldMapOf and the other Fold combinators.
By convention, if there exists a foo method that expects a , then there should be a
Foldable (f a)fooOf method that takes a and a value of type Fold s as.
A Getter is a legal Fold that just ignores the supplied Monoid.
Unlike a Traversal a Fold is read-only. Since a Fold cannot be used to write back
there are no Lens laws that apply.
type Getter s a = forall f. (Functor f, Functor f) => (a -> f a) -> s -> f s Source #
A Getter describes how to retrieve a single value in a way that can be
composed with other LensLike constructions.
Unlike a Lens a Getter is read-only. Since a Getter
cannot be used to write back there are no Lens laws that can be applied to
it. In fact, it is isomorphic to an arbitrary function from (s -> a).
Moreover, a Getter can be used directly as a Fold,
since it just ignores the Applicative.
type As a = Equality' a a Source #
Composable asTypeOf. Useful for constraining excess
polymorphism, foo . (id :: As Int) . bar.
type Equality (s :: k1) (t :: k2) (a :: k1) (b :: k2) = forall k3 (p :: k1 -> k3 -> Type) (f :: k2 -> k3). p a (f b) -> p s (f t) Source #
A witness that (a ~ s, b ~ t).
Note: Composition with an Equality is index-preserving.
type Prism s t a b = forall p f. (forall a. Lift (Either a) p, Applicative f) => p a (f b) -> p s (f t) Source #
A Prism l is a Traversal that can also be turned
around with re to obtain a Getter in the
opposite direction.
There are three laws that a Prism should satisfy:
First, if I re or review a value with a Prism and then preview or use (^?), I will get it back:
previewl (reviewl b) ≡Justb
Second, if you can extract a value a using a Prism l from a value s, then the value s is completely described by l and a:
previewl s ≡Justa ⟹reviewl a ≡ s
Third, if you get non-match t, you can convert it result back to s:
matchingl s ≡Leftt ⟹matchingl t ≡Lefts
The first two laws imply that the Traversal laws hold for every Prism and that we traverse at most 1 element:
lengthOfl x<=1
It may help to think of this as an Iso that can be partial in one direction.
Every Prism is a valid Traversal.
For example, you might have a allows you to always
go from a Prism' Integer NaturalNatural to an Integer, and provide you with tools to check if an Integer is
a Natural and/or to edit one if it is.
nat::Prism'IntegerNaturalnat=prismtoInteger$\ i -> if i<0 thenLefti elseRight(fromIntegeri)
Now we can ask if an Integer is a Natural.
>>>5^?natJust 5
>>>(-5)^?natNothing
We can update the ones that are:
>>>(-3,4) & both.nat *~ 2(-3,8)
And we can then convert from a Natural to an Integer.
>>>5 ^. re nat -- :: Natural5
Similarly we can use a Prism to traverse the Left half of an Either:
>>>Left "hello" & _Left %~ lengthLeft 5
or to construct an Either:
>>>5^.re _LeftLeft 5
such that if you query it with the Prism, you will get your original input back.
>>>5^.re _Left ^? _LeftJust 5
Another interesting way to think of a Prism is as the categorical dual of a Lens
-- a co-Lens, so to speak. This is what permits the construction of outside.
Note: Composition with a Prism is index-preserving.
type Review t b = forall p f. (forall a. Lift (Either a) p, Bifunctor p, Settable f) => Optic' p f t b Source #
type Iso s t a b = forall p f. (Profunctor p, Functor f) => p a (f b) -> p s (f t) Source #
type Setter s t a b = forall f. Settable f => (a -> f b) -> s -> f t Source #
The only LensLike law that can apply to a Setter l is that
setl y (setl x a) ≡setl y a
You can't view a Setter in general, so the other two laws are irrelevant.
However, two Functor laws apply to a Setter:
overlid≡idoverl f.overl g ≡overl (f.g)
These can be stated more directly:
lpure≡purel f.untainted.l g ≡ l (f.untainted.g)
You can compose a Setter with a Lens or a Traversal using (.) from the Prelude
and the result is always only a Setter and nothing more.
>>>over traverse f [a,b,c,d][f a,f b,f c,f d]
>>>over _1 f (a,b)(f a,b)
>>>over (traverse._1) f [(a,b),(c,d)][(f a,b),(f c,d)]
>>>over both f (a,b)(f a,f b)
>>>over (traverse.both) f [(a,b),(c,d)][(f a,f b),(f c,f d)]
type Traversal' s a = Traversal s s a a Source #
typeTraversal'=SimpleTraversal
type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t Source #
A Traversal can be used directly as a Setter or a Fold (but not as a Lens) and provides
the ability to both read and update multiple fields, subject to some relatively weak Traversal laws.
These have also been known as multilenses, but they have the signature and spirit of
traverse::Traversablef =>Traversal(f a) (f b) a b
and the more evocative name suggests their application.
Most of the time the Traversal you will want to use is just traverse, but you can also pass any
Lens or Iso as a Traversal, and composition of a Traversal (or Lens or Iso) with a Traversal (or Lens or Iso)
using (.) forms a valid Traversal.
The laws for a Traversal t follow from the laws for Traversable as stated in "The Essence of the Iterator Pattern".
tpure≡purefmap(t f).t g ≡getCompose.t (Compose.fmapf.g)
One consequence of this requirement is that a Traversal needs to leave the same number of elements as a
candidate for subsequent Traversal that it started with. Another testament to the strength of these laws
is that the caveat expressed in section 5.5 of the "Essence of the Iterator Pattern" about exotic
Traversable instances that traverse the same entry multiple times was actually already ruled out by the
second law in that same paper!
type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t Source #
A Lens is actually a lens family as described in
http://comonad.com/reader/2012/mirrored-lenses/.
With great power comes great responsibility and a Lens is subject to the
three common sense Lens laws:
1) You get back what you put in:
viewl (setl v s) ≡ v
2) Putting back what you got doesn't change anything:
setl (viewl s) s ≡ s
3) Setting twice is the same as setting once:
setl v' (setl v s) ≡setl v' s
These laws are strong enough that the 4 type parameters of a Lens cannot
vary fully independently. For more on how they interact, read the "Why is
it a Lens Family?" section of
http://comonad.com/reader/2012/mirrored-lenses/.
There are some emergent properties of these laws:
1) must be injective for every set l ss This is a consequence of law #1
2) must be surjective, because of law #2, which indicates that it is possible to obtain any set lv from some s such that set s v = s
3) Given just the first two laws you can prove a weaker form of law #3 where the values v that you are setting match:
setl v (setl v s) ≡setl v s
Every Lens can be used directly as a Setter or Traversal.
You can also use a Lens for Getting as if it were a
Fold or Getter.
Since every Lens is a valid Traversal, the
Traversal laws are required of any Lens you create:
lpure≡purefmap(l f).l g ≡getCompose.l (Compose.fmapf.g)
typeLenss t a b = forall f.Functorf =>LensLikef s t a b
type AnEquality' s a = AnEquality s s a a Source #
A Simple AnEquality.
type AnEquality (s :: k1) (t :: k2) (a :: k1) (b :: k2) = Identical a (Proxy b) a (Proxy b) -> Identical a (Proxy b) s (Proxy t) Source #
When you see this as an argument to a function, it expects an Equality.
substEq :: forall s t a b rep (r :: TYPE rep). AnEquality s t a b -> ((s ~ a, t ~ b) => r) -> r Source #
Substituting types with Equality.
mapEq :: forall k1 k2 (s :: k1) (t :: k2) (a :: k1) (b :: k2) (f :: k1 -> Type). AnEquality s t a b -> f s -> f a Source #
We can use Equality to do substitution into anything.
simply :: forall p f s a rep (r :: TYPE rep). (Optic' p f s a -> r) -> Optic' p f s a -> r Source #
This is an adverb that can be used to modify many other Lens combinators to make them require
simple lenses, simple traversals, simple prisms or simple isos as input.
cloneEquality :: AnEquality s t a b -> Equality s t a b Source #
equality :: (s :~: a) -> (b :~: t) -> Equality s t a b Source #
Construct an Equality from explicit equality evidence.
overEquality :: AnEquality s t a b -> p a b -> p s t Source #
Recover a "profunctor lens" form of equality. Reverses fromLeibniz.
underEquality :: AnEquality s t a b -> p t s -> p b a Source #
The opposite of working overEquality is working underEquality.
fromLeibniz :: (Identical a b a b -> Identical a b s t) -> Equality s t a b Source #
Convert a "profunctor lens" form of equality to an equality. Reverses
overEquality.
The type should be understood as
fromLeibniz :: (forall p. p a b -> p s t) -> Equality s t a b
withEquality :: forall s t a b rep (r :: TYPE rep). AnEquality s t a b -> ((s :~: a) -> (b :~: t) -> r) -> r Source #
A version of substEq that provides explicit, rather than implicit,
equality evidence.
type Setting' p s a = Setting p s s a a Source #
This is a convenient alias when defining highly polymorphic code that takes both
ASetter' and AnIndexedSetter' as appropriate. If a function takes this it is
expecting one of those two things based on context.
type Setting p s t a b = p a (Identity b) -> s -> Identity t Source #
This is a convenient alias when defining highly polymorphic code that takes both
ASetter and AnIndexedSetter as appropriate. If a function takes this it is
expecting one of those two things based on context.
type ASetter s t a b = (a -> Identity b) -> s -> Identity t Source #
Running a Setter instantiates it to a concrete type.
When consuming a setter directly to perform a mapping, you can use this type, but most user code will not need to use this type.
mapped :: Functor f => Setter (f a) (f b) a b Source #
This Setter can be used to map over all of the values in a Functor.
fmap≡overmappedfmapDefault≡overtraverse(<$) ≡setmapped
>>>over mapped f [a,b,c][f a,f b,f c]
>>>over mapped (+1) [1,2,3][2,3,4]
>>>set mapped x [a,b,c][x,x,x]
>>>[[a,b],[c]] & mapped.mapped +~ x[[a + x,b + x],[c + x]]
>>>over (mapped._2) length [("hello","world"),("leaders","!!!")][("hello",5),("leaders",3)]
mapped::Functorf =>Setter(f a) (f b) a b
If you want an IndexPreservingSetter use .setting fmap
lifted :: Monad m => Setter (m a) (m b) a b Source #
This setter can be used to modify all of the values in a Monad.
You sometimes have to use this rather than mapped -- due to
temporary insanity Functor was not a superclass of Monad until
GHC 7.10.
liftM≡overlifted
>>>over lifted f [a,b,c][f a,f b,f c]
>>>set lifted b (Just a)Just b
If you want an IndexPreservingSetter use .setting liftM
contramapped :: Functor f => Setter (f b) (f a) a b Source #
This Setter can be used to map over all of the inputs to a Functor.
gmap≡overcontramapped
>>>getPredicate (over contramapped (*2) (Predicate even)) 5True
>>>getOp (over contramapped (*5) (Op show)) 100"500"
>>>Prelude.map ($ 1) $ over (mapped . _Unwrapping' Op . contramapped) (*12) [(*2),(+1),(^3)][24,13,1728]
argument :: Profunctor p => Setter (p b r) (p a r) a b Source #
This Setter can be used to map over the input of a Profunctor.
The most common Profunctor to use this with is (->).
>>>(argument %~ f) g xg (f x)
>>>(argument %~ show) length [1,2,3]7
>>>(argument %~ f) h x yh (f x) y
Map over the argument of the result of a function -- i.e., its second argument:
>>>(mapped.argument %~ f) h x yh x (f y)
argument::Setter(b -> r) (a -> r) a b
sets :: (Profunctor p, Profunctor q, Settable f) => (p a b -> q s t) -> Optical p q f s t a b Source #
Build a Setter, IndexedSetter or IndexPreservingSetter depending on your choice of Profunctor.
sets:: ((a -> b) -> s -> t) ->Setters t a b
over :: ASetter s t a b -> (a -> b) -> s -> t Source #
Modify the target of a Lens or all the targets of a Setter or Traversal
with a function.
fmap≡overmappedfmapDefault≡overtraversesets.over≡idover.sets≡id
Given any valid Setter l, you can also rely on the law:
overl f.overl g =overl (f.g)
e.g.
>>>over mapped f (over mapped g [a,b,c]) == over mapped (f . g) [a,b,c]True
Another way to view over is to say that it transforms a Setter into a
"semantic editor combinator".
>>>over mapped f (Just a)Just (f a)
>>>over mapped (*10) [1,2,3][10,20,30]
>>>over _1 f (a,b)(f a,b)
>>>over _1 show (10,20)("10",20)
over::Setters t a b -> (a -> b) -> s -> tover::ASetters t a b -> (a -> b) -> s -> t
set :: ASetter s t a b -> b -> s -> t Source #
Replace the target of a Lens or all of the targets of a Setter
or Traversal with a constant value.
(<$) ≡setmapped
>>>set _2 "hello" (1,())(1,"hello")
>>>set mapped () [1,2,3,4][(),(),(),()]
Note: Attempting to set a Fold or Getter will fail at compile time with an
relatively nice error message.
set::Setters t a b -> b -> s -> tset::Isos t a b -> b -> s -> tset::Lenss t a b -> b -> s -> tset::Traversals t a b -> b -> s -> t
set' :: ASetter' s a -> a -> s -> s Source #
Replace the target of a Lens or all of the targets of a Setter'
or Traversal with a constant value, without changing its type.
This is a type restricted version of set, which retains the type of the original.
>>>set' mapped x [a,b,c,d][x,x,x,x]
>>>set' _2 "hello" (1,"world")(1,"hello")
>>>set' mapped 0 [1,2,3,4][0,0,0,0]
Note: Attempting to adjust set' a Fold or Getter will fail at compile time with an
relatively nice error message.
set'::Setter's a -> a -> s -> sset'::Iso's a -> a -> s -> sset'::Lens's a -> a -> s -> sset'::Traversal's a -> a -> s -> s
assign :: MonadState s m => ASetter s s a b -> b -> m () Source #
Replace the target of a Lens or all of the targets of a Setter or Traversal in our monadic
state with a new value, irrespective of the old.
This is an alias for (.=).
>>>execState (do assign _1 c; assign _2 d) (a,b)(c,d)
>>>execState (both .= c) (a,b)(c,c)
assign::MonadStates m =>Iso's a -> a -> m ()assign::MonadStates m =>Lens's a -> a -> m ()assign::MonadStates m =>Traversal's a -> a -> m ()assign::MonadStates m =>Setter's a -> a -> m ()
modifying :: MonadState s m => ASetter s s a b -> (a -> b) -> m () Source #
This is an alias for (%=).
scribe :: (MonadWriter t m, Monoid s) => ASetter s t a b -> b -> m () Source #
Write to a fragment of a larger Writer format.
passing :: MonadWriter w m => Setter w w u v -> m (a, u -> v) -> m a Source #
This is a generalization of pass that allows you to modify just a
portion of the resulting MonadWriter.
censoring :: MonadWriter w m => Setter w w u v -> (u -> v) -> m a -> m a Source #
This is a generalization of censor that allows you to censor just a
portion of the resulting MonadWriter.
locally :: MonadReader s m => ASetter s s a b -> (a -> b) -> m r -> m r Source #
Modify the value of the Reader environment associated with the target of a
Setter, Lens, or Traversal.
locallylida ≡ alocallyl f.locally l g ≡locallyl (f.g)
>>>(1,1) & locally _1 (+1) (uncurry (+))3
>>>"," & locally ($) ("Hello" <>) (<> " world!")"Hello, world!"
locally :: MonadReader s m =>Isos s a b -> (a -> b) -> m r -> m r locally :: MonadReader s m =>Lenss s a b -> (a -> b) -> m r -> m r locally :: MonadReader s m =>Traversals s a b -> (a -> b) -> m r -> m r locally :: MonadReader s m =>Setters s a b -> (a -> b) -> m r -> m r
assignA :: Arrow p => ASetter s t a b -> p s b -> p s t Source #
Run an arrow command and use the output to set all the targets of
a Lens, Setter or Traversal to the result.
assignA can be used very similarly to (<~), except that the type of
the object being modified can change; for example:
runKleisli action ((), (), ()) where
action = assignA _1 (Kleisli (const getVal1))
>>> assignA _2 (Kleisli (const getVal2))
>>> assignA _3 (Kleisli (const getVal3))
getVal1 :: Either String Int
getVal1 = ...
getVal2 :: Either String Bool
getVal2 = ...
getVal3 :: Either String Char
getVal3 = ...
has the type Either String (Int, Bool, Char)
assignA::Arrowp =>Isos t a b -> p s b -> p s tassignA::Arrowp =>Lenss t a b -> p s b -> p s tassignA::Arrowp =>Traversals t a b -> p s b -> p s tassignA::Arrowp =>Setters t a b -> p s b -> p s t
The indexed store can be used to characterize a Lens
and is used by cloneLens.
is isomorphic to
Context a b tnewtype ,
and to Context a b t = Context { runContext :: forall f. Functor f => (a -> f b) -> f t }exists s. (s, .Lens s t a b)
A Context is like a Lens that has already been applied to a some structure.
Constructors
| Context (b -> t) a |
choosing :: Functor f => LensLike f s t a b -> LensLike f s' t' a b -> LensLike f (Either s s') (Either t t') a b Source #
Merge two lenses, getters, setters, folds or traversals.
chosen≡choosingidid
choosing::Getters a ->Getters' a ->Getter(Eithers s') achoosing::Folds a ->Folds' a ->Fold(Eithers s') achoosing::Lens's a ->Lens's' a ->Lens'(Eithers s') achoosing::Traversal's a ->Traversal's' a ->Traversal'(Eithers s') achoosing::Setter's a ->Setter's' a ->Setter'(Eithers s') a
alongside :: LensLike (AlongsideLeft f b') s t a b -> LensLike (AlongsideRight f t) s' t' a' b' -> LensLike f (s, s') (t, t') (a, a') (b, b') Source #
alongside makes a Lens from two other lenses or a Getter from two other getters
by executing them on their respective halves of a product.
>>>(Left a, Right b)^.alongside chosen chosen(a,b)
>>>(Left a, Right b) & alongside chosen chosen .~ (c,d)(Left c,Right d)
alongside::Lenss t a b ->Lenss' t' a' b' ->Lens(s,s') (t,t') (a,a') (b,b')alongside::Getters a ->Getters' a' ->Getter(s,s') (a,a')
We can always retrieve a () from any type.
>>>"hello"^.united()
>>>"hello" & united .~ ()"hello"
class Field19 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to the 19th field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 19th field of a tuple.
_19 :: (Generic s, Generic t, GIxed N18 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 19th field of a tuple.
Instances
| Field19 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s') s s' Source # | |
Defined in Control.Lens.Tuple | |
class Field18 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to the 18th field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 18th field of a tuple.
_18 :: (Generic s, Generic t, GIxed N17 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 18th field of a tuple.
Instances
| Field18 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r') r r' Source # | |
Defined in Control.Lens.Tuple | |
| Field18 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r', s) r r' Source # | |
Defined in Control.Lens.Tuple | |
class Field17 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to the 17th field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 17th field of a tuple.
_17 :: (Generic s, Generic t, GIxed N16 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 17th field of a tuple.
Instances
| Field17 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q') q q' Source # | |
Defined in Control.Lens.Tuple | |
| Field17 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q', r) q q' Source # | |
Defined in Control.Lens.Tuple | |
| Field17 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q', r, s) q q' Source # | |
Defined in Control.Lens.Tuple | |
class Field16 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to the 16th field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 16th field of a tuple.
_16 :: (Generic s, Generic t, GIxed N15 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 16th field of a tuple.
Instances
| Field16 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p') p p' Source # | |
Defined in Control.Lens.Tuple | |
| Field16 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p', q) p p' Source # | |
Defined in Control.Lens.Tuple | |
| Field16 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p', q, r) p p' Source # | |
Defined in Control.Lens.Tuple | |
| Field16 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p', q, r, s) p p' Source # | |
Defined in Control.Lens.Tuple | |
class Field15 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to the 15th field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 15th field of a tuple.
_15 :: (Generic s, Generic t, GIxed N14 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 15th field of a tuple.
Instances
| Field15 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o') o o' Source # | |
Defined in Control.Lens.Tuple | |
| Field15 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o', p) o o' Source # | |
Defined in Control.Lens.Tuple | |
| Field15 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o', p, q) o o' Source # | |
Defined in Control.Lens.Tuple | |
| Field15 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o', p, q, r) o o' Source # | |
Defined in Control.Lens.Tuple | |
| Field15 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o', p, q, r, s) o o' Source # | |
Defined in Control.Lens.Tuple | |
class Field14 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to the 14th field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 14th field of a tuple.
_14 :: (Generic s, Generic t, GIxed N13 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 14th field of a tuple.
Instances
| Field14 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n') n n' Source # | |
Defined in Control.Lens.Tuple | |
| Field14 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n', o) n n' Source # | |
Defined in Control.Lens.Tuple | |
| Field14 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n', o, p) n n' Source # | |
Defined in Control.Lens.Tuple | |
| Field14 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n', o, p, q) n n' Source # | |
Defined in Control.Lens.Tuple | |
| Field14 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n', o, p, q, r) n n' Source # | |
Defined in Control.Lens.Tuple | |
| Field14 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d, e, f, g, h, i, j, kk, l, m, n', o, p, q, r, s) n n' Source # | |
Defined in Control.Lens.Tuple | |
class Field13 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to the 13th field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 13th field of a tuple.
_13 :: (Generic s, Generic t, GIxed N12 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 13th field of a tuple.
Instances
| Field13 (a, b, c, d, e, f, g, h, i, j, kk, l, m) (a, b, c, d, e, f, g, h, i, j, kk, l, m') m m' Source # | |
Defined in Control.Lens.Tuple | |
| Field13 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n) (a, b, c, d, e, f, g, h, i, j, kk, l, m', n) m m' Source # | |
Defined in Control.Lens.Tuple | |
| Field13 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o) (a, b, c, d, e, f, g, h, i, j, kk, l, m', n, o) m m' Source # | |
Defined in Control.Lens.Tuple | |
| Field13 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a, b, c, d, e, f, g, h, i, j, kk, l, m', n, o, p) m m' Source # | |
Defined in Control.Lens.Tuple | |
| Field13 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b, c, d, e, f, g, h, i, j, kk, l, m', n, o, p, q) m m' Source # | |
Defined in Control.Lens.Tuple | |
| Field13 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c, d, e, f, g, h, i, j, kk, l, m', n, o, p, q, r) m m' Source # | |
Defined in Control.Lens.Tuple | |
| Field13 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d, e, f, g, h, i, j, kk, l, m', n, o, p, q, r, s) m m' Source # | |
Defined in Control.Lens.Tuple | |
class Field12 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to the 12th field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 12th field of a tuple.
_12 :: (Generic s, Generic t, GIxed N11 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 12th field of a tuple.
Instances
| Field12 (a, b, c, d, e, f, g, h, i, j, kk, l) (a, b, c, d, e, f, g, h, i, j, kk, l') l l' Source # | |
Defined in Control.Lens.Tuple | |
| Field12 (a, b, c, d, e, f, g, h, i, j, kk, l, m) (a, b, c, d, e, f, g, h, i, j, kk, l', m) l l' Source # | |
Defined in Control.Lens.Tuple | |
| Field12 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n) (a, b, c, d, e, f, g, h, i, j, kk, l', m, n) l l' Source # | |
Defined in Control.Lens.Tuple | |
| Field12 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o) (a, b, c, d, e, f, g, h, i, j, kk, l', m, n, o) l l' Source # | |
Defined in Control.Lens.Tuple | |
| Field12 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a, b, c, d, e, f, g, h, i, j, kk, l', m, n, o, p) l l' Source # | |
Defined in Control.Lens.Tuple | |
| Field12 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b, c, d, e, f, g, h, i, j, kk, l', m, n, o, p, q) l l' Source # | |
Defined in Control.Lens.Tuple | |
| Field12 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c, d, e, f, g, h, i, j, kk, l', m, n, o, p, q, r) l l' Source # | |
Defined in Control.Lens.Tuple | |
| Field12 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d, e, f, g, h, i, j, kk, l', m, n, o, p, q, r, s) l l' Source # | |
Defined in Control.Lens.Tuple | |
class Field11 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to the 11th field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 11th field of a tuple.
_11 :: (Generic s, Generic t, GIxed N10 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 11th field of a tuple.
Instances
| Field11 (a, b, c, d, e, f, g, h, i, j, kk) (a, b, c, d, e, f, g, h, i, j, kk') kk kk' Source # | |
Defined in Control.Lens.Tuple | |
| Field11 (a, b, c, d, e, f, g, h, i, j, kk, l) (a, b, c, d, e, f, g, h, i, j, kk', l) kk kk' Source # | |
Defined in Control.Lens.Tuple | |
| Field11 (a, b, c, d, e, f, g, h, i, j, kk, l, m) (a, b, c, d, e, f, g, h, i, j, kk', l, m) kk kk' Source # | |
Defined in Control.Lens.Tuple | |
| Field11 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n) (a, b, c, d, e, f, g, h, i, j, kk', l, m, n) kk kk' Source # | |
Defined in Control.Lens.Tuple | |
| Field11 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o) (a, b, c, d, e, f, g, h, i, j, kk', l, m, n, o) kk kk' Source # | |
Defined in Control.Lens.Tuple | |
| Field11 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a, b, c, d, e, f, g, h, i, j, kk', l, m, n, o, p) kk kk' Source # | |
Defined in Control.Lens.Tuple | |
| Field11 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b, c, d, e, f, g, h, i, j, kk', l, m, n, o, p, q) kk kk' Source # | |
Defined in Control.Lens.Tuple | |
| Field11 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c, d, e, f, g, h, i, j, kk', l, m, n, o, p, q, r) kk kk' Source # | |
Defined in Control.Lens.Tuple | |
| Field11 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d, e, f, g, h, i, j, kk', l, m, n, o, p, q, r, s) kk kk' Source # | |
Defined in Control.Lens.Tuple | |
class Field10 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to the 10th field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 10th field of a tuple.
_10 :: (Generic s, Generic t, GIxed N9 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 10th field of a tuple.
Instances
| Field10 (a, b, c, d, e, f, g, h, i, j) (a, b, c, d, e, f, g, h, i, j') j j' Source # | |
Defined in Control.Lens.Tuple | |
| Field10 (a, b, c, d, e, f, g, h, i, j, kk) (a, b, c, d, e, f, g, h, i, j', kk) j j' Source # | |
Defined in Control.Lens.Tuple | |
| Field10 (a, b, c, d, e, f, g, h, i, j, kk, l) (a, b, c, d, e, f, g, h, i, j', kk, l) j j' Source # | |
Defined in Control.Lens.Tuple | |
| Field10 (a, b, c, d, e, f, g, h, i, j, kk, l, m) (a, b, c, d, e, f, g, h, i, j', kk, l, m) j j' Source # | |
Defined in Control.Lens.Tuple | |
| Field10 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n) (a, b, c, d, e, f, g, h, i, j', kk, l, m, n) j j' Source # | |
Defined in Control.Lens.Tuple | |
| Field10 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o) (a, b, c, d, e, f, g, h, i, j', kk, l, m, n, o) j j' Source # | |
Defined in Control.Lens.Tuple | |
| Field10 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a, b, c, d, e, f, g, h, i, j', kk, l, m, n, o, p) j j' Source # | |
Defined in Control.Lens.Tuple | |
| Field10 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b, c, d, e, f, g, h, i, j', kk, l, m, n, o, p, q) j j' Source # | |
Defined in Control.Lens.Tuple | |
| Field10 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c, d, e, f, g, h, i, j', kk, l, m, n, o, p, q, r) j j' Source # | |
Defined in Control.Lens.Tuple | |
| Field10 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d, e, f, g, h, i, j', kk, l, m, n, o, p, q, r, s) j j' Source # | |
Defined in Control.Lens.Tuple | |
class Field9 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to the 9th field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 9th field of a tuple.
_9 :: (Generic s, Generic t, GIxed N8 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 9th field of a tuple.
Instances
| Field9 (a, b, c, d, e, f, g, h, i) (a, b, c, d, e, f, g, h, i') i i' Source # | |
Defined in Control.Lens.Tuple | |
| Field9 (a, b, c, d, e, f, g, h, i, j) (a, b, c, d, e, f, g, h, i', j) i i' Source # | |
Defined in Control.Lens.Tuple | |
| Field9 (a, b, c, d, e, f, g, h, i, j, kk) (a, b, c, d, e, f, g, h, i', j, kk) i i' Source # | |
Defined in Control.Lens.Tuple | |
| Field9 (a, b, c, d, e, f, g, h, i, j, kk, l) (a, b, c, d, e, f, g, h, i', j, kk, l) i i' Source # | |
Defined in Control.Lens.Tuple | |
| Field9 (a, b, c, d, e, f, g, h, i, j, kk, l, m) (a, b, c, d, e, f, g, h, i', j, kk, l, m) i i' Source # | |
Defined in Control.Lens.Tuple | |
| Field9 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n) (a, b, c, d, e, f, g, h, i', j, kk, l, m, n) i i' Source # | |
Defined in Control.Lens.Tuple | |
| Field9 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o) (a, b, c, d, e, f, g, h, i', j, kk, l, m, n, o) i i' Source # | |
Defined in Control.Lens.Tuple | |
| Field9 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a, b, c, d, e, f, g, h, i', j, kk, l, m, n, o, p) i i' Source # | |
Defined in Control.Lens.Tuple | |
| Field9 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b, c, d, e, f, g, h, i', j, kk, l, m, n, o, p, q) i i' Source # | |
Defined in Control.Lens.Tuple | |
| Field9 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c, d, e, f, g, h, i', j, kk, l, m, n, o, p, q, r) i i' Source # | |
Defined in Control.Lens.Tuple | |
| Field9 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d, e, f, g, h, i', j, kk, l, m, n, o, p, q, r, s) i i' Source # | |
Defined in Control.Lens.Tuple | |
class Field8 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provide access to the 8th field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 8th field of a tuple.
_8 :: (Generic s, Generic t, GIxed N7 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 8th field of a tuple.
Instances
| Field8 (a, b, c, d, e, f, g, h) (a, b, c, d, e, f, g, h') h h' Source # | |
Defined in Control.Lens.Tuple | |
| Field8 (a, b, c, d, e, f, g, h, i) (a, b, c, d, e, f, g, h', i) h h' Source # | |
Defined in Control.Lens.Tuple | |
| Field8 (a, b, c, d, e, f, g, h, i, j) (a, b, c, d, e, f, g, h', i, j) h h' Source # | |
Defined in Control.Lens.Tuple | |
| Field8 (a, b, c, d, e, f, g, h, i, j, kk) (a, b, c, d, e, f, g, h', i, j, kk) h h' Source # | |
Defined in Control.Lens.Tuple | |
| Field8 (a, b, c, d, e, f, g, h, i, j, kk, l) (a, b, c, d, e, f, g, h', i, j, kk, l) h h' Source # | |
Defined in Control.Lens.Tuple | |
| Field8 (a, b, c, d, e, f, g, h, i, j, kk, l, m) (a, b, c, d, e, f, g, h', i, j, kk, l, m) h h' Source # | |
Defined in Control.Lens.Tuple | |
| Field8 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n) (a, b, c, d, e, f, g, h', i, j, kk, l, m, n) h h' Source # | |
Defined in Control.Lens.Tuple | |
| Field8 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o) (a, b, c, d, e, f, g, h', i, j, kk, l, m, n, o) h h' Source # | |
Defined in Control.Lens.Tuple | |
| Field8 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a, b, c, d, e, f, g, h', i, j, kk, l, m, n, o, p) h h' Source # | |
Defined in Control.Lens.Tuple | |
| Field8 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b, c, d, e, f, g, h', i, j, kk, l, m, n, o, p, q) h h' Source # | |
Defined in Control.Lens.Tuple | |
| Field8 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c, d, e, f, g, h', i, j, kk, l, m, n, o, p, q, r) h h' Source # | |
Defined in Control.Lens.Tuple | |
| Field8 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d, e, f, g, h', i, j, kk, l, m, n, o, p, q, r, s) h h' Source # | |
Defined in Control.Lens.Tuple | |
class Field7 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provide access to the 7th field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 7th field of a tuple.
_7 :: (Generic s, Generic t, GIxed N6 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 7th field of a tuple.
Instances
| Field7 (a, b, c, d, e, f, g) (a, b, c, d, e, f, g') g g' Source # | |
Defined in Control.Lens.Tuple | |
| Field7 (a, b, c, d, e, f, g, h) (a, b, c, d, e, f, g', h) g g' Source # | |
Defined in Control.Lens.Tuple | |
| Field7 (a, b, c, d, e, f, g, h, i) (a, b, c, d, e, f, g', h, i) g g' Source # | |
Defined in Control.Lens.Tuple | |
| Field7 (a, b, c, d, e, f, g, h, i, j) (a, b, c, d, e, f, g', h, i, j) g g' Source # | |
Defined in Control.Lens.Tuple | |
| Field7 (a, b, c, d, e, f, g, h, i, j, kk) (a, b, c, d, e, f, g', h, i, j, kk) g g' Source # | |
Defined in Control.Lens.Tuple | |
| Field7 (a, b, c, d, e, f, g, h, i, j, kk, l) (a, b, c, d, e, f, g', h, i, j, kk, l) g g' Source # | |
Defined in Control.Lens.Tuple | |
| Field7 (a, b, c, d, e, f, g, h, i, j, kk, l, m) (a, b, c, d, e, f, g', h, i, j, kk, l, m) g g' Source # | |
Defined in Control.Lens.Tuple | |
| Field7 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n) (a, b, c, d, e, f, g', h, i, j, kk, l, m, n) g g' Source # | |
Defined in Control.Lens.Tuple | |
| Field7 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o) (a, b, c, d, e, f, g', h, i, j, kk, l, m, n, o) g g' Source # | |
Defined in Control.Lens.Tuple | |
| Field7 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a, b, c, d, e, f, g', h, i, j, kk, l, m, n, o, p) g g' Source # | |
Defined in Control.Lens.Tuple | |
| Field7 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b, c, d, e, f, g', h, i, j, kk, l, m, n, o, p, q) g g' Source # | |
Defined in Control.Lens.Tuple | |
| Field7 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c, d, e, f, g', h, i, j, kk, l, m, n, o, p, q, r) g g' Source # | |
Defined in Control.Lens.Tuple | |
| Field7 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d, e, f, g', h, i, j, kk, l, m, n, o, p, q, r, s) g g' Source # | |
Defined in Control.Lens.Tuple | |
class Field6 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to the 6th element of a tuple.
Minimal complete definition
Nothing
Methods
Access the 6th field of a tuple.
_6 :: (Generic s, Generic t, GIxed N5 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 6th field of a tuple.
Instances
| Field6 (a, b, c, d, e, f) (a, b, c, d, e, f') f f' Source # | |
Defined in Control.Lens.Tuple | |
| Field6 (a, b, c, d, e, f, g) (a, b, c, d, e, f', g) f f' Source # | |
Defined in Control.Lens.Tuple | |
| Field6 (a, b, c, d, e, f, g, h) (a, b, c, d, e, f', g, h) f f' Source # | |
Defined in Control.Lens.Tuple | |
| Field6 (a, b, c, d, e, f, g, h, i) (a, b, c, d, e, f', g, h, i) f f' Source # | |
Defined in Control.Lens.Tuple | |
| Field6 (a, b, c, d, e, f, g, h, i, j) (a, b, c, d, e, f', g, h, i, j) f f' Source # | |
Defined in Control.Lens.Tuple | |
| Field6 (a, b, c, d, e, f, g, h, i, j, kk) (a, b, c, d, e, f', g, h, i, j, kk) f f' Source # | |
Defined in Control.Lens.Tuple | |
| Field6 (a, b, c, d, e, f, g, h, i, j, kk, l) (a, b, c, d, e, f', g, h, i, j, kk, l) f f' Source # | |
Defined in Control.Lens.Tuple | |
| Field6 (a, b, c, d, e, f, g, h, i, j, kk, l, m) (a, b, c, d, e, f', g, h, i, j, kk, l, m) f f' Source # | |
Defined in Control.Lens.Tuple | |
| Field6 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n) (a, b, c, d, e, f', g, h, i, j, kk, l, m, n) f f' Source # | |
Defined in Control.Lens.Tuple | |
| Field6 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o) (a, b, c, d, e, f', g, h, i, j, kk, l, m, n, o) f f' Source # | |
Defined in Control.Lens.Tuple | |
| Field6 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a, b, c, d, e, f', g, h, i, j, kk, l, m, n, o, p) f f' Source # | |
Defined in Control.Lens.Tuple | |
| Field6 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b, c, d, e, f', g, h, i, j, kk, l, m, n, o, p, q) f f' Source # | |
Defined in Control.Lens.Tuple | |
| Field6 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c, d, e, f', g, h, i, j, kk, l, m, n, o, p, q, r) f f' Source # | |
Defined in Control.Lens.Tuple | |
| Field6 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d, e, f', g, h, i, j, kk, l, m, n, o, p, q, r, s) f f' Source # | |
Defined in Control.Lens.Tuple | |
class Field5 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to the 5th field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 5th field of a tuple.
_5 :: (Generic s, Generic t, GIxed N4 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 5th field of a tuple.
Instances
| Field5 (a, b, c, d, e) (a, b, c, d, e') e e' Source # | |
Defined in Control.Lens.Tuple | |
| Field5 (a, b, c, d, e, f) (a, b, c, d, e', f) e e' Source # | |
Defined in Control.Lens.Tuple | |
| Field5 (a, b, c, d, e, f, g) (a, b, c, d, e', f, g) e e' Source # | |
Defined in Control.Lens.Tuple | |
| Field5 (a, b, c, d, e, f, g, h) (a, b, c, d, e', f, g, h) e e' Source # | |
Defined in Control.Lens.Tuple | |
| Field5 (a, b, c, d, e, f, g, h, i) (a, b, c, d, e', f, g, h, i) e e' Source # | |
Defined in Control.Lens.Tuple | |
| Field5 (a, b, c, d, e, f, g, h, i, j) (a, b, c, d, e', f, g, h, i, j) e e' Source # | |
Defined in Control.Lens.Tuple | |
| Field5 (a, b, c, d, e, f, g, h, i, j, kk) (a, b, c, d, e', f, g, h, i, j, kk) e e' Source # | |
Defined in Control.Lens.Tuple | |
| Field5 (a, b, c, d, e, f, g, h, i, j, kk, l) (a, b, c, d, e', f, g, h, i, j, kk, l) e e' Source # | |
Defined in Control.Lens.Tuple | |
| Field5 (a, b, c, d, e, f, g, h, i, j, kk, l, m) (a, b, c, d, e', f, g, h, i, j, kk, l, m) e e' Source # | |
Defined in Control.Lens.Tuple | |
| Field5 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n) (a, b, c, d, e', f, g, h, i, j, kk, l, m, n) e e' Source # | |
Defined in Control.Lens.Tuple | |
| Field5 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o) (a, b, c, d, e', f, g, h, i, j, kk, l, m, n, o) e e' Source # | |
Defined in Control.Lens.Tuple | |
| Field5 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a, b, c, d, e', f, g, h, i, j, kk, l, m, n, o, p) e e' Source # | |
Defined in Control.Lens.Tuple | |
| Field5 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b, c, d, e', f, g, h, i, j, kk, l, m, n, o, p, q) e e' Source # | |
Defined in Control.Lens.Tuple | |
| Field5 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c, d, e', f, g, h, i, j, kk, l, m, n, o, p, q, r) e e' Source # | |
Defined in Control.Lens.Tuple | |
| Field5 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d, e', f, g, h, i, j, kk, l, m, n, o, p, q, r, s) e e' Source # | |
Defined in Control.Lens.Tuple | |
class Field4 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provide access to the 4th field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 4th field of a tuple.
_4 :: (Generic s, Generic t, GIxed N3 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 4th field of a tuple.
Instances
| Field4 (a, b, c, d) (a, b, c, d') d d' Source # | |
Defined in Control.Lens.Tuple | |
| Field4 (a, b, c, d, e) (a, b, c, d', e) d d' Source # | |
Defined in Control.Lens.Tuple | |
| Field4 (a, b, c, d, e, f) (a, b, c, d', e, f) d d' Source # | |
Defined in Control.Lens.Tuple | |
| Field4 (a, b, c, d, e, f, g) (a, b, c, d', e, f, g) d d' Source # | |
Defined in Control.Lens.Tuple | |
| Field4 (a, b, c, d, e, f, g, h) (a, b, c, d', e, f, g, h) d d' Source # | |
Defined in Control.Lens.Tuple | |
| Field4 (a, b, c, d, e, f, g, h, i) (a, b, c, d', e, f, g, h, i) d d' Source # | |
Defined in Control.Lens.Tuple | |
| Field4 (a, b, c, d, e, f, g, h, i, j) (a, b, c, d', e, f, g, h, i, j) d d' Source # | |
Defined in Control.Lens.Tuple | |
| Field4 (a, b, c, d, e, f, g, h, i, j, kk) (a, b, c, d', e, f, g, h, i, j, kk) d d' Source # | |
Defined in Control.Lens.Tuple | |
| Field4 (a, b, c, d, e, f, g, h, i, j, kk, l) (a, b, c, d', e, f, g, h, i, j, kk, l) d d' Source # | |
Defined in Control.Lens.Tuple | |
| Field4 (a, b, c, d, e, f, g, h, i, j, kk, l, m) (a, b, c, d', e, f, g, h, i, j, kk, l, m) d d' Source # | |
Defined in Control.Lens.Tuple | |
| Field4 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n) (a, b, c, d', e, f, g, h, i, j, kk, l, m, n) d d' Source # | |
Defined in Control.Lens.Tuple | |
| Field4 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o) (a, b, c, d', e, f, g, h, i, j, kk, l, m, n, o) d d' Source # | |
Defined in Control.Lens.Tuple | |
| Field4 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a, b, c, d', e, f, g, h, i, j, kk, l, m, n, o, p) d d' Source # | |
Defined in Control.Lens.Tuple | |
| Field4 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b, c, d', e, f, g, h, i, j, kk, l, m, n, o, p, q) d d' Source # | |
Defined in Control.Lens.Tuple | |
| Field4 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c, d', e, f, g, h, i, j, kk, l, m, n, o, p, q, r) d d' Source # | |
Defined in Control.Lens.Tuple | |
| Field4 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c, d', e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) d d' Source # | |
Defined in Control.Lens.Tuple | |
class Field3 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to the 3rd field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 3rd field of a tuple.
_3 :: (Generic s, Generic t, GIxed N2 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 3rd field of a tuple.
Instances
| Field3 (a, b, c) (a, b, c') c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d) (a, b, c', d) c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d, e) (a, b, c', d, e) c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d, e, f) (a, b, c', d, e, f) c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d, e, f, g) (a, b, c', d, e, f, g) c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d, e, f, g, h) (a, b, c', d, e, f, g, h) c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d, e, f, g, h, i) (a, b, c', d, e, f, g, h, i) c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d, e, f, g, h, i, j) (a, b, c', d, e, f, g, h, i, j) c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d, e, f, g, h, i, j, kk) (a, b, c', d, e, f, g, h, i, j, kk) c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d, e, f, g, h, i, j, kk, l) (a, b, c', d, e, f, g, h, i, j, kk, l) c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d, e, f, g, h, i, j, kk, l, m) (a, b, c', d, e, f, g, h, i, j, kk, l, m) c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n) (a, b, c', d, e, f, g, h, i, j, kk, l, m, n) c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o) (a, b, c', d, e, f, g, h, i, j, kk, l, m, n, o) c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a, b, c', d, e, f, g, h, i, j, kk, l, m, n, o, p) c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b, c', d, e, f, g, h, i, j, kk, l, m, n, o, p, q) c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b, c', d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) c c' Source # | |
Defined in Control.Lens.Tuple | |
| Field3 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b, c', d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) c c' Source # | |
Defined in Control.Lens.Tuple | |
class Field2 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to the 2nd field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 2nd field of a tuple.
>>>_2 .~ "hello" $ (1,(),3,4)(1,"hello",3,4)
>>>(1,2,3,4) & _2 *~ 3(1,6,3,4)
>>>_2 print (1,2)2 (1,())
anyOf_2:: (s ->Bool) -> (a, s) ->Booltraverse._2:: (Applicativef,Traversablet) => (a -> f b) -> t (s, a) -> f (t (s, b))foldMapOf(traverse._2) :: (Traversablet,Monoidm) => (s -> m) -> t (b, s) -> m
_2 :: (Generic s, Generic t, GIxed N1 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 2nd field of a tuple.
>>>_2 .~ "hello" $ (1,(),3,4)(1,"hello",3,4)
>>>(1,2,3,4) & _2 *~ 3(1,6,3,4)
>>>_2 print (1,2)2 (1,())
anyOf_2:: (s ->Bool) -> (a, s) ->Booltraverse._2:: (Applicativef,Traversablet) => (a -> f b) -> t (s, a) -> f (t (s, b))foldMapOf(traverse._2) :: (Traversablet,Monoidm) => (s -> m) -> t (b, s) -> m
Instances
| Field2 (a, b) (a, b') b b' Source # |
|
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c) (a, b', c) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c, d) (a, b', c, d) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 ((f :*: g) p) ((f :*: g') p) (g p) (g' p) Source # | |
| Field2 (Product f g a) (Product f g' a) (g a) (g' a) Source # | |
| Field2 (a, b, c, d, e) (a, b', c, d, e) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c, d, e, f) (a, b', c, d, e, f) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c, d, e, f, g) (a, b', c, d, e, f, g) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c, d, e, f, g, h) (a, b', c, d, e, f, g, h) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c, d, e, f, g, h, i) (a, b', c, d, e, f, g, h, i) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c, d, e, f, g, h, i, j) (a, b', c, d, e, f, g, h, i, j) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c, d, e, f, g, h, i, j, kk) (a, b', c, d, e, f, g, h, i, j, kk) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c, d, e, f, g, h, i, j, kk, l) (a, b', c, d, e, f, g, h, i, j, kk, l) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c, d, e, f, g, h, i, j, kk, l, m) (a, b', c, d, e, f, g, h, i, j, kk, l, m) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n) (a, b', c, d, e, f, g, h, i, j, kk, l, m, n) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o) (a, b', c, d, e, f, g, h, i, j, kk, l, m, n, o) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a, b', c, d, e, f, g, h, i, j, kk, l, m, n, o, p) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a, b', c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a, b', c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) b b' Source # | |
Defined in Control.Lens.Tuple | |
| Field2 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a, b', c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) b b' Source # | |
Defined in Control.Lens.Tuple | |
class Field1 s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
Provides access to 1st field of a tuple.
Minimal complete definition
Nothing
Methods
Access the 1st field of a tuple (and possibly change its type).
>>>(1,2)^._11
>>>_1 .~ "hello" $ (1,2)("hello",2)
>>>(1,2) & _1 .~ "hello"("hello",2)
>>>_1 putStrLn ("hello","world")hello ((),"world")
This can also be used on larger tuples as well:
>>>(1,2,3,4,5) & _1 +~ 41(42,2,3,4,5)
_1::Lens(a,b) (a',b) a a'_1::Lens(a,b,c) (a',b,c) a a'_1::Lens(a,b,c,d) (a',b,c,d) a a' ..._1::Lens(a,b,c,d,e,f,g,h,i) (a',b,c,d,e,f,g,h,i) a a'
_1 :: (Generic s, Generic t, GIxed N0 (Rep s) (Rep t) a b) => Lens s t a b Source #
Access the 1st field of a tuple (and possibly change its type).
>>>(1,2)^._11
>>>_1 .~ "hello" $ (1,2)("hello",2)
>>>(1,2) & _1 .~ "hello"("hello",2)
>>>_1 putStrLn ("hello","world")hello ((),"world")
This can also be used on larger tuples as well:
>>>(1,2,3,4,5) & _1 +~ 41(42,2,3,4,5)
_1::Lens(a,b) (a',b) a a'_1::Lens(a,b,c) (a',b,c) a a'_1::Lens(a,b,c,d) (a',b,c,d) a a' ..._1::Lens(a,b,c,d,e,f,g,h,i) (a',b,c,d,e,f,g,h,i) a a'
Instances
| Field1 (Identity a) (Identity b) a b Source # | |
| Field1 (a, b) (a', b) a a' Source # |
|
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c) (a', b, c) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c, d) (a', b, c, d) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 ((f :*: g) p) ((f' :*: g) p) (f p) (f' p) Source # | |
| Field1 (Product f g a) (Product f' g a) (f a) (f' a) Source # | |
| Field1 (a, b, c, d, e) (a', b, c, d, e) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c, d, e, f) (a', b, c, d, e, f) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c, d, e, f, g) (a', b, c, d, e, f, g) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c, d, e, f, g, h) (a', b, c, d, e, f, g, h) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c, d, e, f, g, h, i) (a', b, c, d, e, f, g, h, i) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c, d, e, f, g, h, i, j) (a', b, c, d, e, f, g, h, i, j) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c, d, e, f, g, h, i, j, kk) (a', b, c, d, e, f, g, h, i, j, kk) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c, d, e, f, g, h, i, j, kk, l) (a', b, c, d, e, f, g, h, i, j, kk, l) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c, d, e, f, g, h, i, j, kk, l, m) (a', b, c, d, e, f, g, h, i, j, kk, l, m) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n) (a', b, c, d, e, f, g, h, i, j, kk, l, m, n) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o) (a', b, c, d, e, f, g, h, i, j, kk, l, m, n, o) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) (a', b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) (a', b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) (a', b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r) a a' Source # | |
Defined in Control.Lens.Tuple | |
| Field1 (a, b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) (a', b, c, d, e, f, g, h, i, j, kk, l, m, n, o, p, q, r, s) a a' Source # | |
Defined in Control.Lens.Tuple | |
newtype Bazaar1 p a b t Source #
This is used to characterize a Traversal.
a.k.a. indexed Cartesian store comonad, indexed Kleene store comonad, or an indexed FunList.
http://twanvl.nl/blog/haskell/non-regular1
A Bazaar1 is like a Traversal that has already been applied to some structure.
Where a holds an Context a b ta and a function from b to
t, a holds Bazaar1 a b tN as and a function from N
bs to t, (where N might be infinite).
Mnemonically, a Bazaar1 holds many stores and you can easily add more.
This is a final encoding of Bazaar1.
Constructors
| Bazaar1 | |
Fields
| |
Instances
| Profunctor p => Bizarre1 p (Bazaar1 p) Source # | |
Defined in Control.Lens.Internal.Bazaar Methods bazaar1 :: Applicative f => p a (f b) -> Bazaar1 p a b t -> f t Source # | |
| IndexedFunctor (Bazaar1 p) Source # | |
| Functor (Bazaar1 p a b) Source # | |
newtype Bazaar p a b t Source #
This is used to characterize a Traversal.
a.k.a. indexed Cartesian store comonad, indexed Kleene store comonad, or an indexed FunList.
http://twanvl.nl/blog/haskell/non-regular1
A Bazaar is like a Traversal that has already been applied to some structure.
Where a holds an Context a b ta and a function from b to
t, a holds Bazaar a b tN as and a function from N
bs to t, (where N might be infinite).
Mnemonically, a Bazaar holds many stores and you can easily add more.
This is a final encoding of Bazaar.
Constructors
| Bazaar | |
Fields
| |
Instances
| Profunctor p => Bizarre p (Bazaar p) Source # | |
Defined in Control.Lens.Internal.Bazaar Methods bazaar :: Applicative f => p a (f b) -> Bazaar p a b t -> f t Source # | |
| IndexedFunctor (Bazaar p) Source # | |
| Functor (Bazaar p a b) Source # | |
| Applicative (Bazaar p a b) Source # | |
Defined in Control.Lens.Internal.Bazaar Methods pure :: a0 -> Bazaar p a b a0 # (<*>) :: Bazaar p a b (a0 -> b0) -> Bazaar p a b a0 -> Bazaar p a b b0 # liftA2 :: (a0 -> b0 -> c) -> Bazaar p a b a0 -> Bazaar p a b b0 -> Bazaar p a b c # (*>) :: Bazaar p a b a0 -> Bazaar p a b b0 -> Bazaar p a b b0 # (<*) :: Bazaar p a b a0 -> Bazaar p a b b0 -> Bazaar p a b a0 # | |
This provides a way to peek at the internal structure of a
Traversal or IndexedTraversal
Instances
| Functor (Magma i t b) Source # | |
| Foldable (Magma i t b) Source # | |
Defined in Control.Lens.Internal.Magma Methods fold :: Monoid m => Magma i t b m -> m # foldMap :: Monoid m => (a -> m) -> Magma i t b a -> m # foldr :: (a -> b0 -> b0) -> b0 -> Magma i t b a -> b0 # foldr' :: (a -> b0 -> b0) -> b0 -> Magma i t b a -> b0 # foldl :: (b0 -> a -> b0) -> b0 -> Magma i t b a -> b0 # foldl' :: (b0 -> a -> b0) -> b0 -> Magma i t b a -> b0 # foldr1 :: (a -> a -> a) -> Magma i t b a -> a # foldl1 :: (a -> a -> a) -> Magma i t b a -> a # toList :: Magma i t b a -> [a] # null :: Magma i t b a -> Bool # length :: Magma i t b a -> Int # elem :: Eq a => a -> Magma i t b a -> Bool # maximum :: Ord a => Magma i t b a -> a # minimum :: Ord a => Magma i t b a -> a # | |
| Traversable (Magma i t b) Source # | |
Defined in Control.Lens.Internal.Magma | |
| (Show i, Show a) => Show (Magma i t b a) Source # | |
type Accessing p m s a = p a (Const m a) -> s -> Const m s Source #
This is a convenient alias used when consuming (indexed) getters and (indexed) folds in a highly general fashion.
type Getting r s a = (a -> Const r a) -> s -> Const r s Source #
When you see this in a type signature it indicates that you can
pass the function a Lens, Getter,
Traversal, Fold,
Prism, Iso, or one of
the indexed variants, and it will just "do the right thing".
Most Getter combinators are able to be used with both a Getter or a
Fold in limited situations, to do so, they need to be
monomorphic in what we are going to extract with Const. To be compatible
with Lens, Traversal and
Iso we also restricted choices of the irrelevant t and
b parameters.
If a function accepts a , then when Getting r s ar is a Monoid, then
you can pass a Fold (or
Traversal), otherwise you can only pass this a
Getter or Lens.
view :: MonadReader s m => Getting a s a -> m a Source #
View the value pointed to by a Getter, Iso or
Lens or the result of folding over all the results of a
Fold or Traversal that points
at a monoidal value.
view.to≡id
>>>view (to f) af a
>>>view _2 (1,"hello")"hello"
>>>view (to succ) 56
>>>view (_2._1) ("hello",("world","!!!"))"world"
As view is commonly used to access the target of a Getter or obtain a monoidal summary of the targets of a Fold,
It may be useful to think of it as having one of these more restricted signatures:
view::Getters a -> s -> aview::Monoidm =>Folds m -> s -> mview::Iso's a -> s -> aview::Lens's a -> s -> aview::Monoidm =>Traversal's m -> s -> m
In a more general setting, such as when working with a Monad transformer stack you can use:
view::MonadReaders m =>Getters a -> m aview:: (MonadReaders m,Monoida) =>Folds a -> m aview::MonadReaders m =>Iso's a -> m aview::MonadReaders m =>Lens's a -> m aview:: (MonadReaders m,Monoida) =>Traversal's a -> m a
views :: MonadReader s m => LensLike' (Const r) s a -> (a -> r) -> m r Source #
View a function of the value pointed to by a Getter or Lens or the result of
folding over the result of mapping the targets of a Fold or
Traversal.
viewsl f ≡view(l.tof)
>>>views (to f) g ag (f a)
>>>views _2 length (1,"hello")5
As views is commonly used to access the target of a Getter or obtain a monoidal summary of the targets of a Fold,
It may be useful to think of it as having one of these more restricted signatures:
views::Getters a -> (a -> r) -> s -> rviews::Monoidm =>Folds a -> (a -> m) -> s -> mviews::Iso's a -> (a -> r) -> s -> rviews::Lens's a -> (a -> r) -> s -> rviews::Monoidm =>Traversal's a -> (a -> m) -> s -> m
In a more general setting, such as when working with a Monad transformer stack you can use:
views::MonadReaders m =>Getters a -> (a -> r) -> m rviews:: (MonadReaders m,Monoidr) =>Folds a -> (a -> r) -> m rviews::MonadReaders m =>Iso's a -> (a -> r) -> m rviews::MonadReaders m =>Lens's a -> (a -> r) -> m rviews:: (MonadReaders m,Monoidr) =>Traversal's a -> (a -> r) -> m r
views::MonadReaders m =>Gettingr s a -> (a -> r) -> m r
use :: MonadState s m => Getting a s a -> m a Source #
Use the target of a Lens, Iso, or
Getter in the current state, or use a summary of a
Fold or Traversal that points
to a monoidal value.
>>>evalState (use _1) (a,b)a
>>>evalState (use _1) ("hello","world")"hello"
use::MonadStates m =>Getters a -> m ause:: (MonadStates m,Monoidr) =>Folds r -> m ruse::MonadStates m =>Iso's a -> m ause::MonadStates m =>Lens's a -> m ause:: (MonadStates m,Monoidr) =>Traversal's r -> m r
uses :: MonadState s m => LensLike' (Const r) s a -> (a -> r) -> m r Source #
Use the target of a Lens, Iso or
Getter in the current state, or use a summary of a
Fold or Traversal that
points to a monoidal value.
>>>evalState (uses _1 length) ("hello","world")5
uses::MonadStates m =>Getters a -> (a -> r) -> m ruses:: (MonadStates m,Monoidr) =>Folds a -> (a -> r) -> m ruses::MonadStates m =>Lens's a -> (a -> r) -> m ruses::MonadStates m =>Iso's a -> (a -> r) -> m ruses:: (MonadStates m,Monoidr) =>Traversal's a -> (a -> r) -> m r
uses::MonadStates m =>Gettingr s t a b -> (a -> r) -> m r
listening :: MonadWriter w m => Getting u w u -> m a -> m (a, u) Source #
This is a generalized form of listen that only extracts the portion of
the log that is focused on by a Getter. If given a Fold or a Traversal
then a monoidal summary of the parts of the log that are visited will be
returned.
listening::MonadWriterw m =>Getterw u -> m a -> m (a, u)listening::MonadWriterw m =>Lens'w u -> m a -> m (a, u)listening::MonadWriterw m =>Iso'w u -> m a -> m (a, u)listening:: (MonadWriterw m,Monoidu) =>Foldw u -> m a -> m (a, u)listening:: (MonadWriterw m,Monoidu) =>Traversal'w u -> m a -> m (a, u)listening:: (MonadWriterw m,Monoidu) =>Prism'w u -> m a -> m (a, u)
listenings :: MonadWriter w m => Getting v w u -> (u -> v) -> m a -> m (a, v) Source #
This is a generalized form of listen that only extracts the portion of
the log that is focused on by a Getter. If given a Fold or a Traversal
then a monoidal summary of the parts of the log that are visited will be
returned.
listenings::MonadWriterw m =>Getterw u -> (u -> v) -> m a -> m (a, v)listenings::MonadWriterw m =>Lens'w u -> (u -> v) -> m a -> m (a, v)listenings::MonadWriterw m =>Iso'w u -> (u -> v) -> m a -> m (a, v)listenings:: (MonadWriterw m,Monoidv) =>Foldw u -> (u -> v) -> m a -> m (a, v)listenings:: (MonadWriterw m,Monoidv) =>Traversal'w u -> (u -> v) -> m a -> m (a, v)listenings:: (MonadWriterw m,Monoidv) =>Prism'w u -> (u -> v) -> m a -> m (a, v)
getting :: (Profunctor p, Profunctor q, Functor f, Functor f) => Optical p q f s t a b -> Optical' p q f s a Source #
Coerce a Getter-compatible Optical to an Optical'. This
is useful when using a Traversal that is not simple as a Getter or a
Fold.
getting::Traversals t a b ->Folds agetting::Lenss t a b ->Getters agetting::IndexedTraversali s t a b ->IndexedFoldi s agetting::IndexedLensi s t a b ->IndexedGetteri s a
class (Magnified m ~ Magnified n, MonadReader b m, MonadReader a n) => Magnify m n b a | m -> b, n -> a, m a -> n, n b -> m where Source #
This class allows us to use magnify part of the environment, changing the environment supplied by
many different Monad transformers. Unlike zoom this can change the environment of a deeply nested Monad transformer.
Also, unlike zoom, this can be used with any valid Getter, but cannot be used with a Traversal or Fold.
Methods
magnify :: ((Functor (Magnified m c), Functor (Magnified m c)) => LensLike' (Magnified m c) a b) -> m c -> n c infixr 2 Source #
Run a monadic action in a larger environment than it was defined in, using a Getter.
This acts like local, but can in many cases change the type of the environment as well.
This is commonly used to lift actions in a simpler Reader Monad into a Monad with a larger environment type.
This can be used to edit pretty much any Monad transformer stack with an environment in it:
>>>(1,2) & magnify _2 (+1)3
>>>flip Reader.runReader (1,2) $ magnify _1 Reader.ask1
>>>flip Reader.runReader (1,2,[10..20]) $ magnify (_3._tail) Reader.ask[11,12,13,14,15,16,17,18,19,20]
The type can be read as
magnify :: LensLike' (Magnified m c) a b -> m c -> n c
but the higher-rank constraints make it easier to apply magnify to a
Getter in highly-polymorphic code.
magnify::Getters a -> (a -> r) -> s -> rmagnify::Monoidr =>Folds a -> (a -> r) -> s -> r
magnify::Monoidw =>Getters t ->RWSt w st c ->RWSs w st cmagnify:: (Monoidw,Monoidc) =>Folds a ->RWSa w st c ->RWSs w st c ...
Instances
| Magnify m n b a => Magnify (IdentityT m) (IdentityT n) b a Source # | |
| Magnify ((->) b :: Type -> Type) ((->) a :: Type -> Type) b a Source # |
|
| Monad m => Magnify (ReaderT b m) (ReaderT a m) b a Source # | |
| (Monad m, Monoid w) => Magnify (RWST b w s m) (RWST a w s m) b a Source # | |
| (Monad m, Monoid w) => Magnify (RWST b w s m) (RWST a w s m) b a Source # | |
class (MonadState s m, MonadState t n) => Zoom m n s t | m -> s, n -> t, m t -> n, n s -> m where Source #
This class allows us to use zoom in, changing the State supplied by
many different Monad transformers, potentially quite
deep in a Monad transformer stack.
Methods
zoom :: LensLike' (Zoomed m c) t s -> m c -> n c infixr 2 Source #
Run a monadic action in a larger State than it was defined in,
using a Lens' or Traversal'.
This is commonly used to lift actions in a simpler State
Monad into a State Monad with a larger State type.
When applied to a Traversal' over
multiple values, the actions for each target are executed sequentially
and the results are aggregated.
This can be used to edit pretty much any Monad transformer stack with a State in it!
>>>flip State.evalState (a,b) $ zoom _1 $ use ida
>>>flip State.execState (a,b) $ zoom _1 $ id .= c(c,b)
>>>flip State.execState [(a,b),(c,d)] $ zoom traverse $ _2 %= f[(a,f b),(c,f d)]
>>>flip State.runState [(a,b),(c,d)] $ zoom traverse $ _2 <%= f(f b <> f d <> mempty,[(a,f b),(c,f d)])
>>>flip State.evalState (a,b) $ zoom both (use id)a <> b
zoom::Monadm =>Lens's t ->StateTt m a ->StateTs m azoom:: (Monadm,Monoidc) =>Traversal's t ->StateTt m c ->StateTs m czoom:: (Monadm,Monoidw) =>Lens's t ->RWSTr w t m c ->RWSTr w s m czoom:: (Monadm,Monoidw,Monoidc) =>Traversal's t ->RWSTr w t m c ->RWSTr w s m czoom:: (Monadm,Monoidw,Errore) =>Lens's t ->ErrorTe (RWSTr w t m) c ->ErrorTe (RWSTr w s m) czoom:: (Monadm,Monoidw,Monoidc,Errore) =>Traversal's t ->ErrorTe (RWSTr w t m) c ->ErrorTe (RWSTr w s m) c ...
Instances
| Zoom m n s t => Zoom (ListT m) (ListT n) s t Source # | |
| Zoom m n s t => Zoom (MaybeT m) (MaybeT n) s t Source # | |
| Zoom m n s t => Zoom (IdentityT m) (IdentityT n) s t Source # | |
| (Error e, Zoom m n s t) => Zoom (ErrorT e m) (ErrorT e n) s t Source # | |
| Zoom m n s t => Zoom (ExceptT e m) (ExceptT e n) s t Source # | |
| Monad z => Zoom (StateT s z) (StateT t z) s t Source # | |
| Monad z => Zoom (StateT s z) (StateT t z) s t Source # | |
| (Monoid w, Zoom m n s t) => Zoom (WriterT w m) (WriterT w n) s t Source # | |
| (Monoid w, Zoom m n s t) => Zoom (WriterT w m) (WriterT w n) s t Source # | |
| Zoom m n s t => Zoom (ReaderT e m) (ReaderT e n) s t Source # | |
| (Monoid w, Monad z) => Zoom (RWST r w s z) (RWST r w t z) s t Source # | |
| (Monoid w, Monad z) => Zoom (RWST r w s z) (RWST r w t z) s t Source # | |
type family Magnified (m :: * -> *) :: * -> * -> * Source #
This type family is used by Magnify to describe the common effect type.
Instances
| type Magnified (IdentityT m) Source # | |
Defined in Control.Lens.Zoom | |
| type Magnified ((->) b :: Type -> Type) Source # | |
| type Magnified (ReaderT b m) Source # | |
Defined in Control.Lens.Zoom | |
| type Magnified (RWST a w s m) Source # | |
Defined in Control.Lens.Zoom | |
| type Magnified (RWST a w s m) Source # | |
Defined in Control.Lens.Zoom | |
type family Zoomed (m :: * -> *) :: * -> * -> * Source #
This type family is used by Zoom to describe the common effect type.
Instances
| type Zoomed (ListT m) Source # | |
Defined in Control.Lens.Zoom | |
| type Zoomed (MaybeT m) Source # | |
Defined in Control.Lens.Zoom | |
| type Zoomed (IdentityT m) Source # | |
Defined in Control.Lens.Zoom | |
| type Zoomed (ErrorT e m) Source # | |
Defined in Control.Lens.Zoom | |
| type Zoomed (ExceptT e m) Source # | |
Defined in Control.Lens.Zoom | |
| type Zoomed (StateT s z) Source # | |
Defined in Control.Lens.Zoom | |
| type Zoomed (StateT s z) Source # | |
Defined in Control.Lens.Zoom | |
| type Zoomed (WriterT w m) Source # | |
Defined in Control.Lens.Zoom | |
| type Zoomed (WriterT w m) Source # | |
Defined in Control.Lens.Zoom | |
| type Zoomed (ReaderT e m) Source # | |
Defined in Control.Lens.Zoom | |
| type Zoomed (RWST r w s z) Source # | |
Defined in Control.Lens.Zoom | |
| type Zoomed (RWST r w s z) Source # | |
Defined in Control.Lens.Zoom | |
re :: AReview t b -> Getter b t Source #
Turn a Prism or Iso around to build a Getter.
If you have an Iso, from is a more powerful version of this function
that will return an Iso instead of a mere Getter.
>>>5 ^.re _LeftLeft 5
>>>6 ^.re (_Left.unto succ)Left 7
review≡view.rereviews≡views.rereuse≡use.rereuses≡uses.re
re::Prisms t a b ->Getterb tre::Isos t a b ->Getterb t
review :: MonadReader b m => AReview t b -> m t Source #
This can be used to turn an Iso or Prism around and view a value (or the current environment) through it the other way.
review≡view.rereview.unto≡id
>>>review _Left "mustard"Left "mustard"
>>>review (unto succ) 56
Usually review is used in the (->) Monad with a Prism or Iso, in which case it may be useful to think of
it as having one of these more restricted type signatures:
review::Iso's a -> a -> sreview::Prism's a -> a -> s
However, when working with a Monad transformer stack, it is sometimes useful to be able to review the current environment, in which case
it may be beneficial to think of it as having one of these slightly more liberal type signatures:
review::MonadReadera m =>Iso's a -> m sreview::MonadReadera m =>Prism's a -> m s
reviews :: MonadReader b m => AReview t b -> (t -> r) -> m r Source #
This can be used to turn an Iso or Prism around and view a value (or the current environment) through it the other way,
applying a function.
reviews≡views.rereviews(untof) g ≡ g.f
>>>reviews _Left isRight "mustard"False
>>>reviews (unto succ) (*2) 38
Usually this function is used in the (->) Monad with a Prism or Iso, in which case it may be useful to think of
it as having one of these more restricted type signatures:
reviews::Iso's a -> (s -> r) -> a -> rreviews::Prism's a -> (s -> r) -> a -> r
However, when working with a Monad transformer stack, it is sometimes useful to be able to review the current environment, in which case
it may be beneficial to think of it as having one of these slightly more liberal type signatures:
reviews::MonadReadera m =>Iso's a -> (s -> r) -> m rreviews::MonadReadera m =>Prism's a -> (s -> r) -> m r
reuse :: MonadState b m => AReview t b -> m t Source #
This can be used to turn an Iso or Prism around and use a value (or the current environment) through it the other way.
reuse≡use.rereuse.unto≡gets
>>>evalState (reuse _Left) 5Left 5
>>>evalState (reuse (unto succ)) 56
reuse::MonadStatea m =>Prism's a -> m sreuse::MonadStatea m =>Iso's a -> m s
reuses :: MonadState b m => AReview t b -> (t -> r) -> m r Source #
This can be used to turn an Iso or Prism around and use the current state through it the other way,
applying a function.
reuses≡uses.rereuses(untof) g ≡gets(g.f)
>>>evalState (reuses _Left isLeft) (5 :: Int)True
reuses::MonadStatea m =>Prism's a -> (s -> r) -> m rreuses::MonadStatea m =>Iso's a -> (s -> r) -> m r
type APrism s t a b = Market a b a (Identity b) -> Market a b s (Identity t) Source #
If you see this in a signature for a function, the function is expecting a Prism.
withPrism :: APrism s t a b -> ((b -> t) -> (s -> Either t a) -> r) -> r Source #
Convert APrism to the pair of functions that characterize it.
clonePrism :: APrism s t a b -> Prism s t a b Source #
Clone a Prism so that you can reuse the same monomorphically typed Prism for different purposes.
See cloneLens and cloneTraversal for examples of why you might want to do this.
without :: APrism s t a b -> APrism u v c d -> Prism (Either s u) (Either t v) (Either a c) (Either b d) Source #
aside :: APrism s t a b -> Prism (e, s) (e, t) (e, a) (e, b) Source #
Use a Prism to work over part of a structure.
below :: Traversable f => APrism' s a -> Prism' (f s) (f a) Source #
lift a Prism through a Traversable functor, giving a Prism that matches only if all the elements of the container match the Prism.
>>>[Left 1, Right "foo", Left 4, Right "woot"]^..below _Right[]
>>>[Right "hail hydra!", Right "foo", Right "blah", Right "woot"]^..below _Right[["hail hydra!","foo","blah","woot"]]
matching :: APrism s t a b -> s -> Either t a Source #
Retrieve the value targeted by a Prism or return the
original value while allowing the type to change if it does
not match.
>>>matching _Just (Just 12)Right 12
>>>matching _Just (Nothing :: Maybe Int) :: Either (Maybe Bool) IntLeft Nothing
_Left :: Prism (Either a c) (Either b c) a b Source #
This Prism provides a Traversal for tweaking the Left half of an Either:
>>>over _Left (+1) (Left 2)Left 3
>>>over _Left (+1) (Right 2)Right 2
>>>Right 42 ^._Left :: String""
>>>Left "hello" ^._Left"hello"
It also can be turned around to obtain the embedding into the Left half of an Either:
>>>_Left # 5Left 5
>>>5^.re _LeftLeft 5
_Right :: Prism (Either c a) (Either c b) a b Source #
This Prism provides a Traversal for tweaking the Right half of an Either:
>>>over _Right (+1) (Left 2)Left 2
>>>over _Right (+1) (Right 2)Right 3
>>>Right "hello" ^._Right"hello"
>>>Left "hello" ^._Right :: [Double][]
It also can be turned around to obtain the embedding into the Right half of an Either:
>>>_Right # 5Right 5
>>>5^.re _RightRight 5
_Just :: Prism (Maybe a) (Maybe b) a b Source #
This Prism provides a Traversal for tweaking the target of the value of Just in a Maybe.
>>>over _Just (+1) (Just 2)Just 3
Unlike traverse this is a Prism, and so you can use it to inject as well:
>>>_Just # 5Just 5
>>>5^.re _JustJust 5
Interestingly,
m^?_Just≡ m
>>>Just x ^? _JustJust x
>>>Nothing ^? _JustNothing
nearly :: a -> (a -> Bool) -> Prism' a () Source #
This Prism compares for approximate equality with a given value and a predicate for testing,
an example where the value is the empty list and the predicate checks that a list is empty (same
as _Empty with the AsEmpty list instance):
>>>nearly [] null # ()[]>>>[1,2,3,4] ^? nearly [] nullNothing
nearly[]null::Prism'[a] ()
To comply with the Prism laws the arguments you supply to nearly a p are somewhat constrained.
We assume p x holds iff x ≡ a. Under that assumption then this is a valid Prism.
This is useful when working with a type where you can test equality for only a subset of its values, and the prism selects such a value.
_Show :: (Read a, Show a) => Prism' String a Source #
This is an improper prism for text formatting based on Read and Show.
This Prism is "improper" in the sense that it normalizes the text formatting, but round tripping
is idempotent given sane 'Read'/'Show' instances.
>>>_Show # 2"2"
>>>"EQ" ^? _Show :: Maybe OrderingJust EQ
_Show≡prism'showreadMaybe
foldring :: (Functor f, Applicative f) => ((a -> f a -> f a) -> f a -> s -> f a) -> LensLike f s t a b Source #
repeated :: Applicative f => LensLike' f a a Source #
replicated :: Int -> Fold a a Source #
A Fold that replicates its input n times.
replicaten ≡toListOf(replicatedn)
>>>5^..replicated 20[5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5]
iterated :: Applicative f => (a -> a) -> LensLike' f a a Source #
filtered :: (forall a. Lift (Either a) p, Applicative f) => (a -> Bool) -> Optic' p f a a Source #
Obtain a Fold that can be composed with to filter another Lens, Iso, Getter, Fold (or Traversal).
Note: This is not a legal Traversal, unless you are very careful not to invalidate the predicate on the target.
Note: This is also not a legal Prism, unless you are very careful not to inject a value that fails the predicate.
As a counter example, consider that given evens = the second filtered evenTraversal law is violated:
overevenssucc.overevenssucc/=overevens (succ.succ)
So, in order for this to qualify as a legal Traversal you can only use it for actions that preserve the result of the predicate!
>>>[1..10]^..folded.filtered even[2,4,6,8,10]
This will preserve an index if it is present.
foldMapOf :: Getting r s a -> (a -> r) -> s -> r Source #
Map each part of a structure viewed through a Lens, Getter,
Fold or Traversal to a monoid and combine the results.
>>>foldMapOf (folded . both . _Just) Sum [(Just 21, Just 21)]Sum {getSum = 42}
foldMap=foldMapOffolded
foldMapOf≡viewsifoldMapOfl =foldMapOfl.Indexed
foldMapOf::Getters a -> (a -> r) -> s -> rfoldMapOf::Monoidr =>Folds a -> (a -> r) -> s -> rfoldMapOf::Semigroupr =>Fold1s a -> (a -> r) -> s -> rfoldMapOf::Lens's a -> (a -> r) -> s -> rfoldMapOf::Iso's a -> (a -> r) -> s -> rfoldMapOf::Monoidr =>Traversal's a -> (a -> r) -> s -> rfoldMapOf::Semigroupr =>Traversal1's a -> (a -> r) -> s -> rfoldMapOf::Monoidr =>Prism's a -> (a -> r) -> s -> r
foldMapOf::Gettingr s a -> (a -> r) -> s -> r
foldOf :: Getting a s a -> s -> a Source #
Combine the elements of a structure viewed through a Lens, Getter,
Fold or Traversal using a monoid.
>>>foldOf (folded.folded) [[Sum 1,Sum 4],[Sum 8, Sum 8],[Sum 21]]Sum {getSum = 42}
fold=foldOffolded
foldOf≡view
foldOf::Getters m -> s -> mfoldOf::Monoidm =>Folds m -> s -> mfoldOf::Lens's m -> s -> mfoldOf::Iso's m -> s -> mfoldOf::Monoidm =>Traversal's m -> s -> mfoldOf::Monoidm =>Prism's m -> s -> m
foldrOf :: Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r Source #
Right-associative fold of parts of a structure that are viewed through a Lens, Getter, Fold or Traversal.
foldr≡foldrOffolded
foldrOf::Getters a -> (a -> r -> r) -> r -> s -> rfoldrOf::Folds a -> (a -> r -> r) -> r -> s -> rfoldrOf::Lens's a -> (a -> r -> r) -> r -> s -> rfoldrOf::Iso's a -> (a -> r -> r) -> r -> s -> rfoldrOf::Traversal's a -> (a -> r -> r) -> r -> s -> rfoldrOf::Prism's a -> (a -> r -> r) -> r -> s -> r
ifoldrOfl ≡foldrOfl.Indexed
foldrOf::Getting(Endor) s a -> (a -> r -> r) -> r -> s -> r
foldlOf :: Getting (Dual (Endo r)) s a -> (r -> a -> r) -> r -> s -> r Source #
Left-associative fold of the parts of a structure that are viewed through a Lens, Getter, Fold or Traversal.
foldl≡foldlOffolded
foldlOf::Getters a -> (r -> a -> r) -> r -> s -> rfoldlOf::Folds a -> (r -> a -> r) -> r -> s -> rfoldlOf::Lens's a -> (r -> a -> r) -> r -> s -> rfoldlOf::Iso's a -> (r -> a -> r) -> r -> s -> rfoldlOf::Traversal's a -> (r -> a -> r) -> r -> s -> rfoldlOf::Prism's a -> (r -> a -> r) -> r -> s -> r
toNonEmptyOf :: Getting (NonEmptyDList a) s a -> s -> NonEmpty a Source #
Extract a NonEmpty of the targets of Fold1.
>>>toNonEmptyOf both1 ("hello", "world")"hello" :| ["world"]
toNonEmptyOf::Getters a -> s -> NonEmpty atoNonEmptyOf::Fold1s a -> s -> NonEmpty atoNonEmptyOf::Lens's a -> s -> NonEmpty atoNonEmptyOf::Iso's a -> s -> NonEmpty atoNonEmptyOf::Traversal1's a -> s -> NonEmpty atoNonEmptyOf::Prism's a -> s -> NonEmpty a
andOf :: Getting All s Bool -> s -> Bool Source #
Returns True if every target of a Fold is True.
>>>andOf both (True,False)False>>>andOf both (True,True)True
and≡andOffolded
andOf::GettersBool-> s ->BoolandOf::FoldsBool-> s ->BoolandOf::Lens'sBool-> s ->BoolandOf::Iso'sBool-> s ->BoolandOf::Traversal'sBool-> s ->BoolandOf::Prism'sBool-> s ->Bool
orOf :: Getting Any s Bool -> s -> Bool Source #
Returns True if any target of a Fold is True.
>>>orOf both (True,False)True>>>orOf both (False,False)False
or≡orOffolded
orOf::GettersBool-> s ->BoolorOf::FoldsBool-> s ->BoolorOf::Lens'sBool-> s ->BoolorOf::Iso'sBool-> s ->BoolorOf::Traversal'sBool-> s ->BoolorOf::Prism'sBool-> s ->Bool
anyOf :: Getting Any s a -> (a -> Bool) -> s -> Bool Source #
Returns True if any target of a Fold satisfies a predicate.
>>>anyOf both (=='x') ('x','y')True>>>import Data.Data.Lens>>>anyOf biplate (== "world") (((),2::Int),"hello",("world",11::Int))True
any≡anyOffolded
ianyOfl ≡anyOfl.Indexed
anyOf::Getters a -> (a ->Bool) -> s ->BoolanyOf::Folds a -> (a ->Bool) -> s ->BoolanyOf::Lens's a -> (a ->Bool) -> s ->BoolanyOf::Iso's a -> (a ->Bool) -> s ->BoolanyOf::Traversal's a -> (a ->Bool) -> s ->BoolanyOf::Prism's a -> (a ->Bool) -> s ->Bool
allOf :: Getting All s a -> (a -> Bool) -> s -> Bool Source #
Returns True if every target of a Fold satisfies a predicate.
>>>allOf both (>=3) (4,5)True>>>allOf folded (>=2) [1..10]False
all≡allOffolded
iallOfl =allOfl.Indexed
allOf::Getters a -> (a ->Bool) -> s ->BoolallOf::Folds a -> (a ->Bool) -> s ->BoolallOf::Lens's a -> (a ->Bool) -> s ->BoolallOf::Iso's a -> (a ->Bool) -> s ->BoolallOf::Traversal's a -> (a ->Bool) -> s ->BoolallOf::Prism's a -> (a ->Bool) -> s ->Bool
noneOf :: Getting Any s a -> (a -> Bool) -> s -> Bool Source #
Returns True only if no targets of a Fold satisfy a predicate.
>>>noneOf each (is _Nothing) (Just 3, Just 4, Just 5)True>>>noneOf (folded.folded) (<10) [[13,99,20],[3,71,42]]False
inoneOfl =noneOfl.Indexed
noneOf::Getters a -> (a ->Bool) -> s ->BoolnoneOf::Folds a -> (a ->Bool) -> s ->BoolnoneOf::Lens's a -> (a ->Bool) -> s ->BoolnoneOf::Iso's a -> (a ->Bool) -> s ->BoolnoneOf::Traversal's a -> (a ->Bool) -> s ->BoolnoneOf::Prism's a -> (a ->Bool) -> s ->Bool
productOf :: Num a => Getting (Endo (Endo a)) s a -> s -> a Source #
Calculate the Product of every number targeted by a Fold.
>>>productOf both (4,5)20>>>productOf folded [1,2,3,4,5]120
product≡productOffolded
This operation may be more strict than you would expect. If you
want a lazier version use ala Product . foldMapOf
productOf::Numa =>Getters a -> s -> aproductOf::Numa =>Folds a -> s -> aproductOf::Numa =>Lens's a -> s -> aproductOf::Numa =>Iso's a -> s -> aproductOf::Numa =>Traversal's a -> s -> aproductOf::Numa =>Prism's a -> s -> a
sumOf :: Num a => Getting (Endo (Endo a)) s a -> s -> a Source #
Calculate the Sum of every number targeted by a Fold.
>>>sumOf both (5,6)11>>>sumOf folded [1,2,3,4]10>>>sumOf (folded.both) [(1,2),(3,4)]10>>>import Data.Data.Lens>>>sumOf biplate [(1::Int,[]),(2,[(3::Int,4::Int)])] :: Int10
sum≡sumOffolded
This operation may be more strict than you would expect. If you
want a lazier version use ala Sum . foldMapOf
sumOf_1::Numa => (a, b) -> asumOf(folded._1) :: (Foldablef,Numa) => f (a, b) -> a
sumOf::Numa =>Getters a -> s -> asumOf::Numa =>Folds a -> s -> asumOf::Numa =>Lens's a -> s -> asumOf::Numa =>Iso's a -> s -> asumOf::Numa =>Traversal's a -> s -> asumOf::Numa =>Prism's a -> s -> a
traverseOf_ :: Functor f => Getting (Traversed r f) s a -> (a -> f r) -> s -> f () Source #
Traverse over all of the targets of a Fold (or Getter), computing an Applicative (or Functor)-based answer,
but unlike traverseOf do not construct a new structure. traverseOf_ generalizes
traverse_ to work over any Fold.
When passed a Getter, traverseOf_ can work over any Functor, but when passed a Fold, traverseOf_ requires
an Applicative.
>>>traverseOf_ both putStrLn ("hello","world")hello world
traverse_≡traverseOf_folded
traverseOf__2::Functorf => (c -> f r) -> (d, c) -> f ()traverseOf__Left::Applicativef => (a -> f b) ->Eithera c -> f ()
itraverseOf_l ≡traverseOf_l.Indexed
The rather specific signature of traverseOf_ allows it to be used as if the signature was any of:
traverseOf_::Functorf =>Getters a -> (a -> f r) -> s -> f ()traverseOf_::Applicativef =>Folds a -> (a -> f r) -> s -> f ()traverseOf_::Functorf =>Lens's a -> (a -> f r) -> s -> f ()traverseOf_::Functorf =>Iso's a -> (a -> f r) -> s -> f ()traverseOf_::Applicativef =>Traversal's a -> (a -> f r) -> s -> f ()traverseOf_::Applicativef =>Prism's a -> (a -> f r) -> s -> f ()
forOf_ :: Functor f => Getting (Traversed r f) s a -> s -> (a -> f r) -> f () Source #
Traverse over all of the targets of a Fold (or Getter), computing an Applicative (or Functor)-based answer,
but unlike forOf do not construct a new structure. forOf_ generalizes
for_ to work over any Fold.
When passed a Getter, forOf_ can work over any Functor, but when passed a Fold, forOf_ requires
an Applicative.
for_≡forOf_folded
>>>forOf_ both ("hello","world") putStrLnhello world
The rather specific signature of forOf_ allows it to be used as if the signature was any of:
iforOf_l s ≡forOf_l s.Indexed
forOf_::Functorf =>Getters a -> s -> (a -> f r) -> f ()forOf_::Applicativef =>Folds a -> s -> (a -> f r) -> f ()forOf_::Functorf =>Lens's a -> s -> (a -> f r) -> f ()forOf_::Functorf =>Iso's a -> s -> (a -> f r) -> f ()forOf_::Applicativef =>Traversal's a -> s -> (a -> f r) -> f ()forOf_::Applicativef =>Prism's a -> s -> (a -> f r) -> f ()
sequenceAOf_ :: Functor f => Getting (Traversed a f) s (f a) -> s -> f () Source #
Evaluate each action in observed by a Fold on a structure from left to right, ignoring the results.
sequenceA_≡sequenceAOf_folded
>>>sequenceAOf_ both (putStrLn "hello",putStrLn "world")hello world
sequenceAOf_::Functorf =>Getters (f a) -> s -> f ()sequenceAOf_::Applicativef =>Folds (f a) -> s -> f ()sequenceAOf_::Functorf =>Lens's (f a) -> s -> f ()sequenceAOf_::Functorf =>Iso's (f a) -> s -> f ()sequenceAOf_::Applicativef =>Traversal's (f a) -> s -> f ()sequenceAOf_::Applicativef =>Prism's (f a) -> s -> f ()
traverse1Of_ :: Functor f => Getting (TraversedF r f) s a -> (a -> f r) -> s -> f () Source #
Traverse over all of the targets of a Fold1, computing an Apply based answer.
As long as you have Applicative or Functor effect you are better using traverseOf_.
The traverse1Of_ is useful only when you have genuine Apply effect.
>>>traverse1Of_ both1 (\ks -> Map.fromList [ (k, ()) | k <- ks ]) ("abc", "bcd")fromList [('b',()),('c',())]
traverse1Of_::Applyf =>Fold1s a -> (a -> f r) -> s -> f ()
Since: 4.16
for1Of_ :: Functor f => Getting (TraversedF r f) s a -> s -> (a -> f r) -> f () Source #
See forOf_ and traverse1Of_.
>>>for1Of_ both1 ("abc", "bcd") (\ks -> Map.fromList [ (k, ()) | k <- ks ])fromList [('b',()),('c',())]
for1Of_::Applyf =>Fold1s a -> s -> (a -> f r) -> f ()
Since: 4.16
sequence1Of_ :: Functor f => Getting (TraversedF a f) s (f a) -> s -> f () Source #
mapMOf_ :: Monad m => Getting (Sequenced r m) s a -> (a -> m r) -> s -> m () Source #
Map each target of a Fold on a structure to a monadic action, evaluate these actions from left to right, and ignore the results.
>>>mapMOf_ both putStrLn ("hello","world")hello world
mapM_≡mapMOf_folded
mapMOf_::Monadm =>Getters a -> (a -> m r) -> s -> m ()mapMOf_::Monadm =>Folds a -> (a -> m r) -> s -> m ()mapMOf_::Monadm =>Lens's a -> (a -> m r) -> s -> m ()mapMOf_::Monadm =>Iso's a -> (a -> m r) -> s -> m ()mapMOf_::Monadm =>Traversal's a -> (a -> m r) -> s -> m ()mapMOf_::Monadm =>Prism's a -> (a -> m r) -> s -> m ()
forMOf_ :: Monad m => Getting (Sequenced r m) s a -> s -> (a -> m r) -> m () Source #
forMOf_ is mapMOf_ with two of its arguments flipped.
>>>forMOf_ both ("hello","world") putStrLnhello world
forM_≡forMOf_folded
forMOf_::Monadm =>Getters a -> s -> (a -> m r) -> m ()forMOf_::Monadm =>Folds a -> s -> (a -> m r) -> m ()forMOf_::Monadm =>Lens's a -> s -> (a -> m r) -> m ()forMOf_::Monadm =>Iso's a -> s -> (a -> m r) -> m ()forMOf_::Monadm =>Traversal's a -> s -> (a -> m r) -> m ()forMOf_::Monadm =>Prism's a -> s -> (a -> m r) -> m ()
sequenceOf_ :: Monad m => Getting (Sequenced a m) s (m a) -> s -> m () Source #
Evaluate each monadic action referenced by a Fold on the structure from left to right, and ignore the results.
>>>sequenceOf_ both (putStrLn "hello",putStrLn "world")hello world
sequence_≡sequenceOf_folded
sequenceOf_::Monadm =>Getters (m a) -> s -> m ()sequenceOf_::Monadm =>Folds (m a) -> s -> m ()sequenceOf_::Monadm =>Lens's (m a) -> s -> m ()sequenceOf_::Monadm =>Iso's (m a) -> s -> m ()sequenceOf_::Monadm =>Traversal's (m a) -> s -> m ()sequenceOf_::Monadm =>Prism's (m a) -> s -> m ()
asumOf :: Alternative f => Getting (Endo (f a)) s (f a) -> s -> f a Source #
The sum of a collection of actions, generalizing concatOf.
>>>asumOf both ("hello","world")"helloworld"
>>>asumOf each (Nothing, Just "hello", Nothing)Just "hello"
asum≡asumOffolded
asumOf::Alternativef =>Getters (f a) -> s -> f aasumOf::Alternativef =>Folds (f a) -> s -> f aasumOf::Alternativef =>Lens's (f a) -> s -> f aasumOf::Alternativef =>Iso's (f a) -> s -> f aasumOf::Alternativef =>Traversal's (f a) -> s -> f aasumOf::Alternativef =>Prism's (f a) -> s -> f a
msumOf :: MonadPlus m => Getting (Endo (m a)) s (m a) -> s -> m a Source #
The sum of a collection of actions, generalizing concatOf.
>>>msumOf both ("hello","world")"helloworld"
>>>msumOf each (Nothing, Just "hello", Nothing)Just "hello"
msum≡msumOffolded
msumOf::MonadPlusm =>Getters (m a) -> s -> m amsumOf::MonadPlusm =>Folds (m a) -> s -> m amsumOf::MonadPlusm =>Lens's (m a) -> s -> m amsumOf::MonadPlusm =>Iso's (m a) -> s -> m amsumOf::MonadPlusm =>Traversal's (m a) -> s -> m amsumOf::MonadPlusm =>Prism's (m a) -> s -> m a
elemOf :: Eq a => Getting Any s a -> a -> s -> Bool Source #
Does the element occur anywhere within a given Fold of the structure?
>>>elemOf both "hello" ("hello","world")True
elem≡elemOffolded
elemOf::Eqa =>Getters a -> a -> s ->BoolelemOf::Eqa =>Folds a -> a -> s ->BoolelemOf::Eqa =>Lens's a -> a -> s ->BoolelemOf::Eqa =>Iso's a -> a -> s ->BoolelemOf::Eqa =>Traversal's a -> a -> s ->BoolelemOf::Eqa =>Prism's a -> a -> s ->Bool
notElemOf :: Eq a => Getting All s a -> a -> s -> Bool Source #
Does the element not occur anywhere within a given Fold of the structure?
>>>notElemOf each 'd' ('a','b','c')True
>>>notElemOf each 'a' ('a','b','c')False
notElem≡notElemOffolded
notElemOf::Eqa =>Getters a -> a -> s ->BoolnotElemOf::Eqa =>Folds a -> a -> s ->BoolnotElemOf::Eqa =>Iso's a -> a -> s ->BoolnotElemOf::Eqa =>Lens's a -> a -> s ->BoolnotElemOf::Eqa =>Traversal's a -> a -> s ->BoolnotElemOf::Eqa =>Prism's a -> a -> s ->Bool
concatMapOf :: Getting [r] s a -> (a -> [r]) -> s -> [r] Source #
Map a function over all the targets of a Fold of a container and concatenate the resulting lists.
>>>concatMapOf both (\x -> [x, x + 1]) (1,3)[1,2,3,4]
concatMap≡concatMapOffolded
concatMapOf::Getters a -> (a -> [r]) -> s -> [r]concatMapOf::Folds a -> (a -> [r]) -> s -> [r]concatMapOf::Lens's a -> (a -> [r]) -> s -> [r]concatMapOf::Iso's a -> (a -> [r]) -> s -> [r]concatMapOf::Traversal's a -> (a -> [r]) -> s -> [r]
concatOf :: Getting [r] s [r] -> s -> [r] Source #
Concatenate all of the lists targeted by a Fold into a longer list.
>>>concatOf both ("pan","ama")"panama"
concat≡concatOffoldedconcatOf≡view
concatOf::Getters [r] -> s -> [r]concatOf::Folds [r] -> s -> [r]concatOf::Iso's [r] -> s -> [r]concatOf::Lens's [r] -> s -> [r]concatOf::Traversal's [r] -> s -> [r]
lengthOf :: Getting (Endo (Endo Int)) s a -> s -> Int Source #
Calculate the number of targets there are for a Fold in a given container.
Note: This can be rather inefficient for large containers and just like length,
this will not terminate for infinite folds.
length≡lengthOffolded
>>>lengthOf _1 ("hello",())1
>>>lengthOf traverse [1..10]10
>>>lengthOf (traverse.traverse) [[1,2],[3,4],[5,6]]6
lengthOf(folded.folded) :: (Foldablef,Foldableg) => f (g a) ->Int
lengthOf::Getters a -> s ->IntlengthOf::Folds a -> s ->IntlengthOf::Lens's a -> s ->IntlengthOf::Iso's a -> s ->IntlengthOf::Traversal's a -> s ->Int
firstOf :: Getting (Leftmost a) s a -> s -> Maybe a Source #
Retrieve the First entry of a Fold or Traversal or retrieve Just the result
from a Getter or Lens.
The answer is computed in a manner that leaks space less than or preview^?'
and gives you back access to the outermost Just constructor more quickly, but does so
in a way that builds an intermediate structure, and thus may have worse
constant factors. This also means that it can not be used in any MonadReader,
but must instead have s passed as its last argument, unlike preview.
Note: this could been named headOf.
>>>firstOf traverse [1..10]Just 1
>>>firstOf both (1,2)Just 1
>>>firstOf ignored ()Nothing
firstOf::Getters a -> s ->MaybeafirstOf::Folds a -> s ->MaybeafirstOf::Lens's a -> s ->MaybeafirstOf::Iso's a -> s ->MaybeafirstOf::Traversal's a -> s ->Maybea
first1Of :: Getting (First a) s a -> s -> a Source #
Retrieve the First entry of a Fold1 or Traversal1 or the result from a Getter or Lens.
>>>first1Of traverse1 (1 :| [2..10])1
>>>first1Of both1 (1,2)1
Note: this is different from ^..
>>>first1Of traverse1 ([1,2] :| [[3,4],[5,6]])[1,2]
>>>([1,2] :| [[3,4],[5,6]]) ^. traverse1[1,2,3,4,5,6]
first1Of::Getters a -> s -> afirst1Of::Fold1s a -> s -> afirst1Of::Lens's a -> s -> afirst1Of::Iso's a -> s -> afirst1Of::Traversal1's a -> s -> a
lastOf :: Getting (Rightmost a) s a -> s -> Maybe a Source #
Retrieve the Last entry of a Fold or Traversal or retrieve Just the result
from a Getter or Lens.
The answer is computed in a manner that leaks space less than
and gives you back access to the outermost ala Last . foldMapOfJust constructor more quickly, but may have worse
constant factors.
>>>lastOf traverse [1..10]Just 10
>>>lastOf both (1,2)Just 2
>>>lastOf ignored ()Nothing
lastOf::Getters a -> s ->MaybealastOf::Folds a -> s ->MaybealastOf::Lens's a -> s ->MaybealastOf::Iso's a -> s ->MaybealastOf::Traversal's a -> s ->Maybea
last1Of :: Getting (Last a) s a -> s -> a Source #
Retrieve the Last entry of a Fold1 or Traversal1 or retrieve the result
from a Getter or Lens.o
>>>last1Of traverse1 (1 :| [2..10])10
>>>last1Of both1 (1,2)2
last1Of::Getters a -> s ->Maybealast1Of::Fold1s a -> s ->Maybealast1Of::Lens's a -> s ->Maybealast1Of::Iso's a -> s ->Maybealast1Of::Traversal1's a -> s ->Maybea
nullOf :: Getting All s a -> s -> Bool Source #
Returns True if this Fold or Traversal has no targets in the given container.
Note: nullOf on a valid Iso, Lens or Getter should always return False.
null≡nullOffolded
This may be rather inefficient compared to the null check of many containers.
>>>nullOf _1 (1,2)False
>>>nullOf ignored ()True
>>>nullOf traverse []True
>>>nullOf (element 20) [1..10]True
nullOf(folded._1.folded) :: (Foldablef,Foldableg) => f (g a, b) ->Bool
nullOf::Getters a -> s ->BoolnullOf::Folds a -> s ->BoolnullOf::Iso's a -> s ->BoolnullOf::Lens's a -> s ->BoolnullOf::Traversal's a -> s ->Bool
notNullOf :: Getting Any s a -> s -> Bool Source #
Returns True if this Fold or Traversal has any targets in the given container.
A more "conversational" alias for this combinator is has.
Note: notNullOf on a valid Iso, Lens or Getter should always return True.
not.null≡notNullOffolded
This may be rather inefficient compared to the check of many containers.not . null
>>>notNullOf _1 (1,2)True
>>>notNullOf traverse [1..10]True
>>>notNullOf folded []False
>>>notNullOf (element 20) [1..10]False
notNullOf(folded._1.folded) :: (Foldablef,Foldableg) => f (g a, b) ->Bool
notNullOf::Getters a -> s ->BoolnotNullOf::Folds a -> s ->BoolnotNullOf::Iso's a -> s ->BoolnotNullOf::Lens's a -> s ->BoolnotNullOf::Traversal's a -> s ->Bool
maximumOf :: Ord a => Getting (Endo (Endo (Maybe a))) s a -> s -> Maybe a Source #
Obtain the maximum element (if any) targeted by a Fold or Traversal safely.
Note: maximumOf on a valid Iso, Lens or Getter will always return Just a value.
>>>maximumOf traverse [1..10]Just 10
>>>maximumOf traverse []Nothing
>>>maximumOf (folded.filtered even) [1,4,3,6,7,9,2]Just 6
maximum≡fromMaybe(error"empty").maximumOffolded
In the interest of efficiency, This operation has semantics more strict than strictly necessary.
has lazier semantics but could leak memory.rmap getMax (foldMapOf l Max)
maximumOf::Orda =>Getters a -> s ->MaybeamaximumOf::Orda =>Folds a -> s ->MaybeamaximumOf::Orda =>Iso's a -> s ->MaybeamaximumOf::Orda =>Lens's a -> s ->MaybeamaximumOf::Orda =>Traversal's a -> s ->Maybea
maximum1Of :: Ord a => Getting (Max a) s a -> s -> a Source #
Obtain the maximum element targeted by a Fold1 or Traversal1.
>>>maximum1Of traverse1 (1 :| [2..10])10
maximum1Of::Orda =>Getters a -> s -> amaximum1Of::Orda =>Fold1s a -> s -> amaximum1Of::Orda =>Iso's a -> s -> amaximum1Of::Orda =>Lens's a -> s -> amaximum1Of::Orda =>Traversal1's a -> s -> a
minimumOf :: Ord a => Getting (Endo (Endo (Maybe a))) s a -> s -> Maybe a Source #
Obtain the minimum element (if any) targeted by a Fold or Traversal safely.
Note: minimumOf on a valid Iso, Lens or Getter will always return Just a value.
>>>minimumOf traverse [1..10]Just 1
>>>minimumOf traverse []Nothing
>>>minimumOf (folded.filtered even) [1,4,3,6,7,9,2]Just 2
minimum≡fromMaybe(error"empty").minimumOffolded
In the interest of efficiency, This operation has semantics more strict than strictly necessary.
has lazier semantics but could leak memory.rmap getMin (foldMapOf l Min)
minimumOf::Orda =>Getters a -> s ->MaybeaminimumOf::Orda =>Folds a -> s ->MaybeaminimumOf::Orda =>Iso's a -> s ->MaybeaminimumOf::Orda =>Lens's a -> s ->MaybeaminimumOf::Orda =>Traversal's a -> s ->Maybea
minimum1Of :: Ord a => Getting (Min a) s a -> s -> a Source #
Obtain the minimum element targeted by a Fold1 or Traversal1.
>>>minimum1Of traverse1 (1 :| [2..10])1
minimum1Of::Orda =>Getters a -> s -> aminimum1Of::Orda =>Fold1s a -> s -> aminimum1Of::Orda =>Iso's a -> s -> aminimum1Of::Orda =>Lens's a -> s -> aminimum1Of::Orda =>Traversal1's a -> s -> a
maximumByOf :: Getting (Endo (Endo (Maybe a))) s a -> (a -> a -> Ordering) -> s -> Maybe a Source #
Obtain the maximum element (if any) targeted by a Fold, Traversal, Lens, Iso,
or Getter according to a user supplied Ordering.
>>>maximumByOf traverse (compare `on` length) ["mustard","relish","ham"]Just "mustard"
In the interest of efficiency, This operation has semantics more strict than strictly necessary.
maximumBycmp ≡fromMaybe(error"empty").maximumByOffoldedcmp
maximumByOf::Getters a -> (a -> a ->Ordering) -> s ->MaybeamaximumByOf::Folds a -> (a -> a ->Ordering) -> s ->MaybeamaximumByOf::Iso's a -> (a -> a ->Ordering) -> s ->MaybeamaximumByOf::Lens's a -> (a -> a ->Ordering) -> s ->MaybeamaximumByOf::Traversal's a -> (a -> a ->Ordering) -> s ->Maybea
minimumByOf :: Getting (Endo (Endo (Maybe a))) s a -> (a -> a -> Ordering) -> s -> Maybe a Source #
Obtain the minimum element (if any) targeted by a Fold, Traversal, Lens, Iso
or Getter according to a user supplied Ordering.
In the interest of efficiency, This operation has semantics more strict than strictly necessary.
>>>minimumByOf traverse (compare `on` length) ["mustard","relish","ham"]Just "ham"
minimumBycmp ≡fromMaybe(error"empty").minimumByOffoldedcmp
minimumByOf::Getters a -> (a -> a ->Ordering) -> s ->MaybeaminimumByOf::Folds a -> (a -> a ->Ordering) -> s ->MaybeaminimumByOf::Iso's a -> (a -> a ->Ordering) -> s ->MaybeaminimumByOf::Lens's a -> (a -> a ->Ordering) -> s ->MaybeaminimumByOf::Traversal's a -> (a -> a ->Ordering) -> s ->Maybea
findOf :: Getting (Endo (Maybe a)) s a -> (a -> Bool) -> s -> Maybe a Source #
The findOf function takes a Lens (or Getter, Iso, Fold, or Traversal),
a predicate and a structure and returns the leftmost element of the structure
matching the predicate, or Nothing if there is no such element.
>>>findOf each even (1,3,4,6)Just 4
>>>findOf folded even [1,3,5,7]Nothing
findOf::Getters a -> (a ->Bool) -> s ->MaybeafindOf::Folds a -> (a ->Bool) -> s ->MaybeafindOf::Iso's a -> (a ->Bool) -> s ->MaybeafindOf::Lens's a -> (a ->Bool) -> s ->MaybeafindOf::Traversal's a -> (a ->Bool) -> s ->Maybea
find≡findOffoldedifindOfl ≡findOfl.Indexed
A simpler version that didn't permit indexing, would be:
findOf::Getting(Endo(Maybea)) s a -> (a ->Bool) -> s ->MaybeafindOfl p =foldrOfl (a y -> if p a thenJusta else y)Nothing
findMOf :: Monad m => Getting (Endo (m (Maybe a))) s a -> (a -> m Bool) -> s -> m (Maybe a) Source #
The findMOf function takes a Lens (or Getter, Iso, Fold, or Traversal),
a monadic predicate and a structure and returns in the monad the leftmost element of the structure
matching the predicate, or Nothing if there is no such element.
>>>findMOf each ( \x -> print ("Checking " ++ show x) >> return (even x)) (1,3,4,6)"Checking 1" "Checking 3" "Checking 4" Just 4
>>>findMOf each ( \x -> print ("Checking " ++ show x) >> return (even x)) (1,3,5,7)"Checking 1" "Checking 3" "Checking 5" "Checking 7" Nothing
findMOf:: (Monadm,Getters a) -> (a -> mBool) -> s -> m (Maybea)findMOf:: (Monadm,Folds a) -> (a -> mBool) -> s -> m (Maybea)findMOf:: (Monadm,Iso's a) -> (a -> mBool) -> s -> m (Maybea)findMOf:: (Monadm,Lens's a) -> (a -> mBool) -> s -> m (Maybea)findMOf:: (Monadm,Traversal's a) -> (a -> mBool) -> s -> m (Maybea)
findMOffolded:: (Monad m, Foldable f) => (a -> m Bool) -> f a -> m (Maybe a)ifindMOfl ≡findMOfl.Indexed
A simpler version that didn't permit indexing, would be:
findMOf:: Monad m =>Getting(Endo(m (Maybea))) s a -> (a -> mBool) -> s -> m (Maybea)findMOfl p =foldrOfl (a y -> p a >>= x -> if x then return (Justa) else y) $ returnNothing
lookupOf :: Eq k => Getting (Endo (Maybe v)) s (k, v) -> k -> s -> Maybe v Source #
The lookupOf function takes a Fold (or Getter, Traversal,
Lens, Iso, etc.), a key, and a structure containing key/value pairs.
It returns the first value corresponding to the given key. This function
generalizes lookup to work on an arbitrary Fold instead of lists.
>>>lookupOf folded 4 [(2, 'a'), (4, 'b'), (4, 'c')]Just 'b'
>>>lookupOf each 2 [(2, 'a'), (4, 'b'), (4, 'c')]Just 'a'
lookupOf::Eqk =>Folds (k,v) -> k -> s ->Maybev
foldr1Of :: Getting (Endo1 a) s a -> (a -> a -> a) -> s -> a Source #
A variant of foldrOf that has no base case and thus may only be applied
to lenses and structures such that the Lens views at least one element of
the structure.
>>>foldr1Of each (+) (1,2,3,4)10
foldr1Ofl f ≡foldr1f.toListOflfoldr1≡foldr1Offolded
foldr1Of::Getters a -> (a -> a -> a) -> s -> afoldr1Of::Folds a -> (a -> a -> a) -> s -> afoldr1Of::Iso's a -> (a -> a -> a) -> s -> afoldr1Of::Lens's a -> (a -> a -> a) -> s -> afoldr1Of::Traversal's a -> (a -> a -> a) -> s -> a
foldl1Of :: Getting (Dual (Endo1 a)) s a -> (a -> a -> a) -> s -> a Source #
A variant of foldlOf that has no base case and thus may only be applied to lenses and structures such
that the Lens views at least one element of the structure.
>>>foldl1Of each (+) (1,2,3,4)10
foldl1Ofl f ≡foldl1f.toListOflfoldl1≡foldl1Offolded
foldl1Of::Getters a -> (a -> a -> a) -> s -> afoldl1Of::Folds a -> (a -> a -> a) -> s -> afoldl1Of::Iso's a -> (a -> a -> a) -> s -> afoldl1Of::Lens's a -> (a -> a -> a) -> s -> afoldl1Of::Traversal's a -> (a -> a -> a) -> s -> a
foldrOf' :: Getting (Dual (Endo (Endo r))) s a -> (a -> r -> r) -> r -> s -> r Source #
Strictly fold right over the elements of a structure.
foldr'≡foldrOf'folded
foldrOf'::Getters a -> (a -> r -> r) -> r -> s -> rfoldrOf'::Folds a -> (a -> r -> r) -> r -> s -> rfoldrOf'::Iso's a -> (a -> r -> r) -> r -> s -> rfoldrOf'::Lens's a -> (a -> r -> r) -> r -> s -> rfoldrOf'::Traversal's a -> (a -> r -> r) -> r -> s -> r
foldlOf' :: Getting (Endo (Endo r)) s a -> (r -> a -> r) -> r -> s -> r Source #
Fold over the elements of a structure, associating to the left, but strictly.
foldl'≡foldlOf'folded
foldlOf'::Getters a -> (r -> a -> r) -> r -> s -> rfoldlOf'::Folds a -> (r -> a -> r) -> r -> s -> rfoldlOf'::Iso's a -> (r -> a -> r) -> r -> s -> rfoldlOf'::Lens's a -> (r -> a -> r) -> r -> s -> rfoldlOf'::Traversal's a -> (r -> a -> r) -> r -> s -> r
foldrMOf :: Monad m => Getting (Dual (Endo (r -> m r))) s a -> (a -> r -> m r) -> r -> s -> m r Source #
Monadic fold over the elements of a structure, associating to the right, i.e. from right to left.
foldrM≡foldrMOffolded
foldrMOf::Monadm =>Getters a -> (a -> r -> m r) -> r -> s -> m rfoldrMOf::Monadm =>Folds a -> (a -> r -> m r) -> r -> s -> m rfoldrMOf::Monadm =>Iso's a -> (a -> r -> m r) -> r -> s -> m rfoldrMOf::Monadm =>Lens's a -> (a -> r -> m r) -> r -> s -> m rfoldrMOf::Monadm =>Traversal's a -> (a -> r -> m r) -> r -> s -> m r
foldlMOf :: Monad m => Getting (Endo (r -> m r)) s a -> (r -> a -> m r) -> r -> s -> m r Source #
Monadic fold over the elements of a structure, associating to the left, i.e. from left to right.
foldlM≡foldlMOffolded
foldlMOf::Monadm =>Getters a -> (r -> a -> m r) -> r -> s -> m rfoldlMOf::Monadm =>Folds a -> (r -> a -> m r) -> r -> s -> m rfoldlMOf::Monadm =>Iso's a -> (r -> a -> m r) -> r -> s -> m rfoldlMOf::Monadm =>Lens's a -> (r -> a -> m r) -> r -> s -> m rfoldlMOf::Monadm =>Traversal's a -> (r -> a -> m r) -> r -> s -> m r
has :: Getting Any s a -> s -> Bool Source #
Check to see if this Fold or Traversal matches 1 or more entries.
>>>has (element 0) []False
>>>has _Left (Left 12)True
>>>has _Right (Left 12)False
This will always return True for a Lens or Getter.
>>>has _1 ("hello","world")True
has::Getters a -> s ->Boolhas::Folds a -> s ->Boolhas::Iso's a -> s ->Boolhas::Lens's a -> s ->Boolhas::Traversal's a -> s ->Bool
pre :: Getting (First a) s a -> Getter s (Maybe a) Source #
This converts a Fold to a IndexPreservingGetter that returns the first element, if it
exists, as a Maybe.
pre::Getters a ->IndexPreservingGetters (Maybea)pre::Folds a ->IndexPreservingGetters (Maybea)pre::Traversal's a ->IndexPreservingGetters (Maybea)pre::Lens's a ->IndexPreservingGetters (Maybea)pre::Iso's a ->IndexPreservingGetters (Maybea)pre::Prism's a ->IndexPreservingGetters (Maybea)
preview :: MonadReader s m => Getting (First a) s a -> m (Maybe a) Source #
Retrieve the first value targeted by a Fold or Traversal (or Just the result
from a Getter or Lens). See also firstOf and ^?, which are similar with
some subtle differences (explained below).
listToMaybe.toList≡previewfolded
preview=view.pre
Unlike ^?, this function uses a
MonadReader to read the value to be focused in on.
This allows one to pass the value as the last argument by using the
MonadReader instance for (->) s
However, it may also be used as part of some deeply nested transformer stack.
preview uses a monoidal value to obtain the result.
This means that it generally has good performance, but can occasionally cause space leaks
or even stack overflows on some data types.
There is another function, firstOf, which avoids these issues at the cost of
a slight constant performance cost and a little less flexibility.
It may be helpful to think of preview as having one of the following
more specialized types:
preview::Getters a -> s ->Maybeapreview::Folds a -> s ->Maybeapreview::Lens's a -> s ->Maybeapreview::Iso's a -> s ->Maybeapreview::Traversal's a -> s ->Maybea
preview::MonadReaders m =>Getters a -> m (Maybea)preview::MonadReaders m =>Folds a -> m (Maybea)preview::MonadReaders m =>Lens's a -> m (Maybea)preview::MonadReaders m =>Iso's a -> m (Maybea)preview::MonadReaders m =>Traversal's a -> m (Maybea)
preuse :: MonadState s m => Getting (First a) s a -> m (Maybe a) Source #
Retrieve the first value targeted by a Fold or Traversal (or Just the result
from a Getter or Lens) into the current state.
preuse=use.pre
preuse::MonadStates m =>Getters a -> m (Maybea)preuse::MonadStates m =>Folds a -> m (Maybea)preuse::MonadStates m =>Lens's a -> m (Maybea)preuse::MonadStates m =>Iso's a -> m (Maybea)preuse::MonadStates m =>Traversal's a -> m (Maybea)
preuses :: MonadState s m => Getting (First r) s a -> (a -> r) -> m (Maybe r) Source #
Retrieve a function of the first value targeted by a Fold or
Traversal (or Just the result from a Getter or Lens) into the current state.
preuses=uses.pre
preuses::MonadStates m =>Getters a -> (a -> r) -> m (Mayber)preuses::MonadStates m =>Folds a -> (a -> r) -> m (Mayber)preuses::MonadStates m =>Lens's a -> (a -> r) -> m (Mayber)preuses::MonadStates m =>Iso's a -> (a -> r) -> m (Mayber)preuses::MonadStates m =>Traversal's a -> (a -> r) -> m (Mayber)
backwards :: (Profunctor p, Profunctor q) => Optical p q (Backwards f) s t a b -> Optical p q f s t a b Source #
This allows you to traverse the elements of a pretty much any LensLike construction in the opposite order.
This will preserve indexes on Indexed types and will give you the elements of a (finite) Fold or Traversal in the opposite order.
This has no practical impact on a Getter, Setter, Lens or Iso.
NB: To write back through an Iso, you want to use from.
Similarly, to write back through an Prism, you want to use re.
type ATraversal1' s a = ATraversal1 s s a a Source #
typeATraversal1'=SimpleATraversal1
type ATraversal1 s t a b = LensLike (Bazaar1 (->) a b) s t a b Source #
When you see this as an argument to a function, it expects a Traversal1.
type ATraversal' s a = ATraversal s s a a Source #
typeATraversal'=SimpleATraversal
type ATraversal s t a b = LensLike (Bazaar (->) a b) s t a b Source #
When you see this as an argument to a function, it expects a Traversal.
traverseOf :: LensLike f s t a b -> (a -> f b) -> s -> f t Source #
Map each element of a structure targeted by a Lens or Traversal,
evaluate these actions from left to right, and collect the results.
This function is only provided for consistency, id is strictly more general.
>>>traverseOf each print (1,2,3)1 2 3 ((),(),())
traverseOf≡iditraverseOfl ≡traverseOfl.IndexeditraverseOfitraversed≡itraverse
This yields the obvious law:
traverse≡traverseOftraverse
traverseOf::Functorf =>Isos t a b -> (a -> f b) -> s -> f ttraverseOf::Functorf =>Lenss t a b -> (a -> f b) -> s -> f ttraverseOf::Applyf =>Traversal1s t a b -> (a -> f b) -> s -> f ttraverseOf::Applicativef =>Traversals t a b -> (a -> f b) -> s -> f t
forOf :: LensLike f s t a b -> s -> (a -> f b) -> f t Source #
A version of traverseOf with the arguments flipped, such that:
>>>forOf each (1,2,3) print1 2 3 ((),(),())
This function is only provided for consistency, flip is strictly more general.
forOf≡flipforOf≡flip.traverseOf
for≡forOftraverseiforl s ≡forl s.Indexed
forOf::Functorf =>Isos t a b -> s -> (a -> f b) -> f tforOf::Functorf =>Lenss t a b -> s -> (a -> f b) -> f tforOf::Applicativef =>Traversals t a b -> s -> (a -> f b) -> f t
sequenceAOf :: LensLike f s t (f b) b -> s -> f t Source #
Evaluate each action in the structure from left to right, and collect the results.
>>>sequenceAOf both ([1,2],[3,4])[(1,3),(1,4),(2,3),(2,4)]
sequenceA≡sequenceAOftraverse≡traverseidsequenceAOfl ≡traverseOflid≡ lid
sequenceAOf::Functorf =>Isos t (f b) b -> s -> f tsequenceAOf::Functorf =>Lenss t (f b) b -> s -> f tsequenceAOf::Applicativef =>Traversals t (f b) b -> s -> f t
mapMOf :: LensLike (WrappedMonad m) s t a b -> (a -> m b) -> s -> m t Source #
Map each element of a structure targeted by a Lens to a monadic action,
evaluate these actions from left to right, and collect the results.
>>>mapMOf both (\x -> [x, x + 1]) (1,3)[(1,3),(1,4),(2,3),(2,4)]
mapM≡mapMOftraverseimapMOfl ≡forMl.Indexed
mapMOf::Monadm =>Isos t a b -> (a -> m b) -> s -> m tmapMOf::Monadm =>Lenss t a b -> (a -> m b) -> s -> m tmapMOf::Monadm =>Traversals t a b -> (a -> m b) -> s -> m t
forMOf :: LensLike (WrappedMonad m) s t a b -> s -> (a -> m b) -> m t Source #
forMOf is a flipped version of mapMOf, consistent with the definition of forM.
>>>forMOf both (1,3) $ \x -> [x, x + 1][(1,3),(1,4),(2,3),(2,4)]
forM≡forMOftraverseforMOfl ≡flip(mapMOfl)iforMOfl s ≡forMl s.Indexed
forMOf::Monadm =>Isos t a b -> s -> (a -> m b) -> m tforMOf::Monadm =>Lenss t a b -> s -> (a -> m b) -> m tforMOf::Monadm =>Traversals t a b -> s -> (a -> m b) -> m t
sequenceOf :: LensLike (WrappedMonad m) s t (m b) b -> s -> m t Source #
Sequence the (monadic) effects targeted by a Lens in a container from left to right.
>>>sequenceOf each ([1,2],[3,4],[5,6])[(1,3,5),(1,3,6),(1,4,5),(1,4,6),(2,3,5),(2,3,6),(2,4,5),(2,4,6)]
sequence≡sequenceOftraversesequenceOfl ≡mapMOflidsequenceOfl ≡unwrapMonad.lWrapMonad
sequenceOf::Monadm =>Isos t (m b) b -> s -> m tsequenceOf::Monadm =>Lenss t (m b) b -> s -> m tsequenceOf::Monadm =>Traversals t (m b) b -> s -> m t
transposeOf :: LensLike ZipList s t [a] a -> s -> [t] Source #
This generalizes transpose to an arbitrary Traversal.
Note: transpose handles ragged inputs more intelligently, but for non-ragged inputs:
>>>transposeOf traverse [[1,2,3],[4,5,6]][[1,4],[2,5],[3,6]]
transpose≡transposeOftraverse
Since every Lens is a Traversal, we can use this as a form of
monadic strength as well:
transposeOf_2:: (b, [a]) -> [(b, a)]
mapAccumROf :: LensLike (Backwards (State acc)) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t) Source #
This generalizes mapAccumR to an arbitrary Traversal.
mapAccumR≡mapAccumROftraverse
mapAccumROf accumulates State from right to left.
mapAccumROf::Isos t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)mapAccumROf::Lenss t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)mapAccumROf::Traversals t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
mapAccumROf::LensLike(Backwards(Stateacc)) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
mapAccumLOf :: LensLike (State acc) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t) Source #
This generalizes mapAccumL to an arbitrary Traversal.
mapAccumL≡mapAccumLOftraverse
mapAccumLOf accumulates State from left to right.
mapAccumLOf::Isos t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)mapAccumLOf::Lenss t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)mapAccumLOf::Traversals t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
mapAccumLOf::LensLike(Stateacc) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)mapAccumLOfl f acc0 s =swap(runState(l (a ->state(acc ->swap(f acc a))) s) acc0)
both :: Bitraversable r => Traversal (r a a) (r b b) a b Source #
Traverse both parts of a Bitraversable container with matching types.
Usually that type will be a pair. Use each to traverse
the elements of arbitrary homogeneous tuples.
>>>(1,2) & both *~ 10(10,20)
>>>over both length ("hello","world")(5,5)
>>>("hello","world")^.both"helloworld"
both::Traversal(a, a) (b, b) a bboth::Traversal(Eithera a) (Eitherb b) a b
ignored :: Applicative f => pafb -> s -> f s Source #
failover :: Alternative m => LensLike ((,) Any) s t a b -> (a -> b) -> s -> m t Source #
Try to map a function over this Traversal, failing if the Traversal has no targets.
>>>failover (element 3) (*2) [1,2] :: Maybe [Int]Nothing
>>>failover _Left (*2) (Right 4) :: Maybe (Either Int Int)Nothing
>>>failover _Right (*2) (Right 4) :: Maybe (Either Int Int)Just (Right 8)
failover :: Alternative m => Traversal s t a b -> (a -> b) -> s -> m t
type ReifiedPrism' s a = ReifiedPrism s s a a Source #
typeReifiedPrism'=SimpleReifiedPrism
newtype ReifiedPrism s t a b Source #
Reify a ReifiedPrism so it can be stored safely in a container.
type ReifiedIso' s a = ReifiedIso s s a a Source #
typeReifiedIso'=SimpleReifiedIso
newtype ReifiedIso s t a b Source #
Reify an ReifiedIso so it can be stored safely in a container.
type ReifiedSetter' s a = ReifiedSetter s s a a Source #
typeReifiedSetter'=SimpleReifiedSetter
newtype ReifiedSetter s t a b Source #
Reify a ReifiedSetter so it can be stored safely in a container.
newtype ReifiedFold s a Source #
Reify a ReifiedFold so it can be stored safely in a container.
This can also be useful for creatively combining folds as
is isomorphic to ReifiedFold sReaderT s [] and provides similar
instances.
>>>("hello","world")^..runFold ((,) <$> Fold _2 <*> Fold both)[("world","hello"),("world","world")]
Instances
newtype ReifiedGetter s a Source #
Reify a ReifiedGetter so it can be stored safely in a container.
This can also be useful when combining getters in novel ways, as
ReifiedGetter is isomorphic to '(->)' and provides similar instances.
>>>("hello","world","!!!")^.runGetter ((,) <$> Getter _2 <*> Getter (_1.to length))("world",5)
Instances
type ReifiedTraversal' s a = ReifiedTraversal s s a a Source #
newtype ReifiedTraversal s t a b Source #
A form of ReifiedTraversal that can be stored monomorphically in a container.
Constructors
| Traversal | |
Fields
| |
type ReifiedLens' s a = ReifiedLens s s a a Source #
typeReifiedLens'=SimpleReifiedLens
newtype ReifiedLens s t a b Source #
Reify a ReifiedLens so it can be stored safely in a container.
Minimal complete definition
gplate1'
Instances
| GPlated1 (f :: k -> Type) (V1 :: k -> Type) Source # | ignored |
Defined in Control.Lens.Plated Methods gplate1' :: Traversal' (V1 a) (f a) | |
| GPlated1 (f :: k -> Type) (U1 :: k -> Type) Source # | ignored |
Defined in Control.Lens.Plated Methods gplate1' :: Traversal' (U1 a) (f a) | |
| GPlated1 (f :: k -> Type) (URec a :: k -> Type) Source # | ignored |
Defined in Control.Lens.Plated Methods gplate1' :: Traversal' (URec a a0) (f a0) | |
| GPlated1 (f :: k -> Type) (Rec1 g :: k -> Type) Source # | ignored |
Defined in Control.Lens.Plated Methods gplate1' :: Traversal' (Rec1 g a) (f a) | |
| GPlated1 (f :: k -> Type) (Rec1 f :: k -> Type) Source # | match |
Defined in Control.Lens.Plated Methods gplate1' :: Traversal' (Rec1 f a) (f a) | |
| GPlated1 (f :: k -> Type) (K1 i a :: k -> Type) Source # | ignored |
Defined in Control.Lens.Plated Methods gplate1' :: Traversal' (K1 i a a0) (f a0) | |
| (GPlated1 f g, GPlated1 f h) => GPlated1 (f :: k -> Type) (g :*: h :: k -> Type) Source # | recursive match |
Defined in Control.Lens.Plated Methods gplate1' :: Traversal' ((g :*: h) a) (f a) | |
| (GPlated1 f g, GPlated1 f h) => GPlated1 (f :: k -> Type) (g :+: h :: k -> Type) Source # | recursive match |
Defined in Control.Lens.Plated Methods gplate1' :: Traversal' ((g :+: h) a) (f a) | |
| (Traversable t, GPlated1 f g) => GPlated1 (f :: k1 -> Type) (t :.: g :: k1 -> Type) Source # | recursive match under outer |
Defined in Control.Lens.Plated Methods gplate1' :: Traversal' ((t :.: g) a) (f a) | |
| GPlated1 f g => GPlated1 (f :: k -> Type) (M1 i c g :: k -> Type) Source # | recursive match |
Defined in Control.Lens.Plated Methods gplate1' :: Traversal' (M1 i c g a) (f a) | |
| GPlated1 (f :: Type -> Type) Par1 Source # | ignored |
Defined in Control.Lens.Plated Methods gplate1' :: Traversal' (Par1 a) (f a) | |
Minimal complete definition
gplate'
Instances
| GPlated a (V1 :: k -> Type) Source # | |
Defined in Control.Lens.Plated Methods gplate' :: Traversal' (V1 p) a | |
| GPlated a (U1 :: k -> Type) Source # | |
Defined in Control.Lens.Plated Methods gplate' :: Traversal' (U1 p) a | |
| GPlated a (URec b :: k -> Type) Source # | |
Defined in Control.Lens.Plated Methods gplate' :: Traversal' (URec b p) a | |
| GPlated a (K1 i b :: k -> Type) Source # | |
Defined in Control.Lens.Plated Methods gplate' :: Traversal' (K1 i b p) a | |
| GPlated a (K1 i a :: k -> Type) Source # | |
Defined in Control.Lens.Plated Methods gplate' :: Traversal' (K1 i a p) a | |
| (GPlated a f, GPlated a g) => GPlated a (f :*: g :: k -> Type) Source # | |
Defined in Control.Lens.Plated Methods gplate' :: Traversal' ((f :*: g) p) a | |
| (GPlated a f, GPlated a g) => GPlated a (f :+: g :: k -> Type) Source # | |
Defined in Control.Lens.Plated Methods gplate' :: Traversal' ((f :+: g) p) a | |
| GPlated a f => GPlated a (M1 i c f :: k -> Type) Source # | |
Defined in Control.Lens.Plated Methods gplate' :: Traversal' (M1 i c f p) a | |
A Plated type is one where we know how to extract its immediate self-similar children.
Example 1:
import Control.Applicative
import Control.Lens
import Control.Lens.Plated
import Data.Data
import Data.Data.Lens (uniplate)
data Expr = ValInt| Neg Expr | Add Expr Expr deriving (Eq,Ord,Show,Read,Data,Typeable)
instancePlatedExpr whereplatef (Neg e) = Neg<$>f eplatef (Add a b) = Add<$>f a<*>f bplate_ a =purea
or
instancePlatedExpr whereplate=uniplate
Example 2:
import Control.Applicative
import Control.Lens
import Control.Lens.Plated
import Data.Data
import Data.Data.Lens (uniplate)
data Tree a = Bin (Tree a) (Tree a) | Tip a deriving (Eq,Ord,Show,Read,Data,Typeable)
instancePlated(Tree a) whereplatef (Bin l r) = Bin<$>f l<*>f rplate_ t =puret
or
instanceDataa =>Plated(Tree a) whereplate=uniplate
Note the big distinction between these two implementations.
The former will only treat children directly in this tree as descendents, the latter will treat trees contained in the values under the tips also as descendants!
When in doubt, pick a Traversal and just use the various ...Of combinators
rather than pollute Plated with orphan instances!
If you want to find something unplated and non-recursive with biplate
use the ...OnOf variant with ignored, though those usecases are much better served
in most cases by using the existing Lens combinators! e.g.
toListOfbiplate≡universeOnOfbiplateignored
This same ability to explicitly pass the Traversal in question is why there is no
analogue to uniplate's Biplate.
Moreover, since we can allow custom traversals, we implement reasonable defaults for
polymorphic data types, that only traverse into themselves, and not their
polymorphic arguments.
Methods
plate :: Traversal' a a Source #
Instances
| Plated [a] Source # | |
Defined in Control.Lens.Plated Methods plate :: Traversal' [a] [a] Source # | |
| Plated (Tree a) Source # | |
Defined in Control.Lens.Plated | |
| Traversable f => Plated (Cofree f a) Source # | |
Defined in Control.Lens.Plated | |
| Traversable f => Plated (Free f a) Source # | |
Defined in Control.Lens.Plated | |
rewrite :: Plated a => (a -> Maybe a) -> a -> a Source #
Rewrite by applying a rule everywhere you can. Ensures that the rule cannot be applied anywhere in the result:
propRewrite r x =all(isNothing.r) (universe(rewriter x))
Usually transform is more appropriate, but rewrite can give better
compositionality. Given two single transformations f and g, you can
construct \a -> f a which performs both rewrites until a fixed point.<|> g a
rewriteOf :: ASetter a b a b -> (b -> Maybe a) -> a -> b Source #
Rewrite by applying a rule everywhere you can. Ensures that the rule cannot be applied anywhere in the result:
propRewriteOf l r x =all(isNothing.r) (universeOfl (rewriteOfl r x))
Usually transformOf is more appropriate, but rewriteOf can give better
compositionality. Given two single transformations f and g, you can
construct \a -> f a which performs both rewrites until a fixed point.<|> g a
rewriteOf::Iso'a a -> (a ->Maybea) -> a -> arewriteOf::Lens'a a -> (a ->Maybea) -> a -> arewriteOf::Traversal'a a -> (a ->Maybea) -> a -> arewriteOf::Setter'a a -> (a ->Maybea) -> a -> a
rewriteOn :: Plated a => ASetter s t a a -> (a -> Maybe a) -> s -> t Source #
Rewrite recursively over part of a larger structure.
rewriteOn::Plateda =>Iso's a -> (a ->Maybea) -> s -> srewriteOn::Plateda =>Lens's a -> (a ->Maybea) -> s -> srewriteOn::Plateda =>Traversal's a -> (a ->Maybea) -> s -> srewriteOn::Plateda =>ASetter's a -> (a ->Maybea) -> s -> s
rewriteOnOf :: ASetter s t a b -> ASetter a b a b -> (b -> Maybe a) -> s -> t Source #
Rewrite recursively over part of a larger structure using a specified Setter.
rewriteOnOf::Iso's a ->Iso'a a -> (a ->Maybea) -> s -> srewriteOnOf::Lens's a ->Lens'a a -> (a ->Maybea) -> s -> srewriteOnOf::Traversal's a ->Traversal'a a -> (a ->Maybea) -> s -> srewriteOnOf::Setter's a ->Setter'a a -> (a ->Maybea) -> s -> s
rewriteM :: (Monad m, Plated a) => (a -> m (Maybe a)) -> a -> m a Source #
Rewrite by applying a monadic rule everywhere you can. Ensures that the rule cannot be applied anywhere in the result.
rewriteMOf :: Monad m => LensLike (WrappedMonad m) a b a b -> (b -> m (Maybe a)) -> a -> m b Source #
Rewrite by applying a monadic rule everywhere you recursing with a user-specified Traversal.
Ensures that the rule cannot be applied anywhere in the result.
rewriteMOn :: (Monad m, Plated a) => LensLike (WrappedMonad m) s t a a -> (a -> m (Maybe a)) -> s -> m t Source #
Rewrite by applying a monadic rule everywhere inside of a structure located by a user-specified Traversal.
Ensures that the rule cannot be applied anywhere in the result.
rewriteMOnOf :: Monad m => LensLike (WrappedMonad m) s t a b -> LensLike (WrappedMonad m) a b a b -> (b -> m (Maybe a)) -> s -> m t Source #
universe :: Plated a => a -> [a] Source #
Retrieve all of the transitive descendants of a Plated container, including itself.
universeOf :: Getting [a] a a -> a -> [a] Source #
Given a Fold that knows how to locate immediate children, retrieve all of the transitive descendants of a node, including itself.
universeOf::Folda a -> a -> [a]
universeOn :: Plated a => Getting [a] s a -> s -> [a] Source #
universeOnOf :: Getting [a] s a -> Getting [a] a a -> s -> [a] Source #
Given a Fold that knows how to locate immediate children, retrieve all of the transitive descendants of a node, including itself that lie
in a region indicated by another Fold.
toListOfl ≡universeOnOflignored
cosmos :: Plated a => Fold a a Source #
Fold over all transitive descendants of a Plated container, including itself.
cosmosOnOf :: (Applicative f, Functor f) => LensLike' f s a -> LensLike' f a a -> LensLike' f s a Source #
transformOn :: Plated a => ASetter s t a a -> (a -> a) -> s -> t Source #
Transform every element in the tree in a bottom-up manner over a region indicated by a Setter.
transformOn::Plateda =>Traversal's a -> (a -> a) -> s -> stransformOn::Plateda =>Setter's a -> (a -> a) -> s -> s
transformOf :: ASetter a b a b -> (b -> b) -> a -> b Source #
Transform every element by recursively applying a given Setter in a bottom-up manner.
transformOf::Traversal'a a -> (a -> a) -> a -> atransformOf::Setter'a a -> (a -> a) -> a -> a
transformOnOf :: ASetter s t a b -> ASetter a b a b -> (b -> b) -> s -> t Source #
Transform every element in a region indicated by a Setter by recursively applying another Setter
in a bottom-up manner.
transformOnOf::Setter's a ->Traversal'a a -> (a -> a) -> s -> stransformOnOf::Setter's a ->Setter'a a -> (a -> a) -> s -> s
transformM :: (Monad m, Plated a) => (a -> m a) -> a -> m a Source #
Transform every element in the tree, in a bottom-up manner, monadically.
transformMOn :: (Monad m, Plated a) => LensLike (WrappedMonad m) s t a a -> (a -> m a) -> s -> m t Source #
Transform every element in the tree in a region indicated by a supplied Traversal, in a bottom-up manner, monadically.
transformMOn:: (Monadm,Plateda) =>Traversal's a -> (a -> m a) -> s -> m s
transformMOf :: Monad m => LensLike (WrappedMonad m) a b a b -> (b -> m b) -> a -> m b Source #
Transform every element in a tree using a user supplied Traversal in a bottom-up manner with a monadic effect.
transformMOf::Monadm =>Traversal'a a -> (a -> m a) -> a -> m a
transformMOnOf :: Monad m => LensLike (WrappedMonad m) s t a b -> LensLike (WrappedMonad m) a b a b -> (b -> m b) -> s -> m t Source #
Transform every element in a tree that lies in a region indicated by a supplied Traversal, walking with a user supplied Traversal in
a bottom-up manner with a monadic effect.
transformMOnOf::Monadm =>Traversal's a ->Traversal'a a -> (a -> m a) -> s -> m s
composOpFold :: Plated a => b -> (b -> b -> b) -> (a -> b) -> a -> b Source #
Fold the immediate children of a Plated container.
composOpFoldz c f =foldrOfplate(c.f) z
class Strict lazy strict | lazy -> strict, strict -> lazy where Source #
Ad hoc conversion between "strict" and "lazy" versions of a structure,
such as Text or ByteString.
class Bifunctor p => Swapped p where Source #
This class provides for symmetric bifunctors.
Methods
Instances
| Swapped Either Source # | |
| Swapped (,) Source # | |
Defined in Control.Lens.Iso | |
| Swapped ((,,) x) Source # | |
Defined in Control.Lens.Iso | |
| Swapped ((,,,) x y) Source # | |
Defined in Control.Lens.Iso | |
| Swapped ((,,,,) x y z) Source # | |
Defined in Control.Lens.Iso | |
| Swapped p => Swapped (Dual p) Source # | |
| Swapped ((,,,,,) x y z w) Source # | |
Defined in Control.Lens.Iso | |
| Swapped ((,,,,,,) x y z w v) Source # | |
Defined in Control.Lens.Iso | |
| (Functor f, Swapped p) => Swapped (Tannen f p) Source # | |
| (f ~ g, Functor f, Swapped p) => Swapped (Biff p f g) Source # | |
type AnIso s t a b = Exchange a b a (Identity b) -> Exchange a b s (Identity t) Source #
When you see this as an argument to a function, it expects an Iso.
withIso :: forall s t a b rep (r :: TYPE rep). AnIso s t a b -> ((s -> a) -> (b -> t) -> r) -> r Source #
Extract the two functions, one from s -> a and
one from b -> t that characterize an Iso.
cloneIso :: AnIso s t a b -> Iso s t a b Source #
Convert from AnIso back to any Iso.
This is useful when you need to store an isomorphism as a data type inside a container and later reconstitute it as an overloaded function.
See cloneLens or cloneTraversal for more information on why you might want to do this.
au :: Functor f => AnIso s t a b -> ((b -> t) -> f s) -> f a Source #
Based on ala from Conor McBride's work on Epigram.
This version is generalized to accept any Iso, not just a newtype.
>>>au (_Wrapping Sum) foldMap [1,2,3,4]10
You may want to think of this combinator as having the following, simpler type:
au :: AnIso s t a b -> ((b -> t) -> e -> s) -> e -> a
au = xplat . from
auf :: (Functor f, Functor g) => AnIso s t a b -> (f t -> g s) -> f b -> g a Source #
Based on ala' from Conor McBride's work on Epigram.
This version is generalized to accept any Iso, not just a newtype.
For a version you pass the name of the newtype constructor to, see alaf.
>>>auf (_Wrapping Sum) (foldMapOf both) Prelude.length ("hello","world")10
Mnemonically, the German auf plays a similar role to à la, and the combinator
is au with an extra function argument:
auf::Isos t a b -> ((r -> t) -> e -> s) -> (r -> b) -> e -> a
but the signature is general.
Note: The direction of the Iso required for this function changed in lens 4.18 to match up
with the behavior of au. For the old behavior use xplatf or for a version that is compatible
across both old and new versions of lens you can just use coerce!
enum :: Enum a => Iso' Int a Source #
This isomorphism can be used to convert to or from an instance of Enum.
>>>LT^.from enum0
>>>97^.enum :: Char'a'
Note: this is only an isomorphism from the numeric range actually used
and it is a bit of a pleasant fiction, since there are questionable
Enum instances for Double, and Float that exist solely for
[1.0 .. 4.0] sugar and the instances for those and Integer don't
cover all values in their range.
non :: Eq a => a -> Iso' (Maybe a) a Source #
If v is an element of a type a, and a' is a sans the element v, then is an isomorphism from
non v to Maybe a'a.
non≡non'.only
Keep in mind this is only a real isomorphism if you treat the domain as being .Maybe (a sans v)
This is practically quite useful when you want to have a Map where all the entries should have non-zero values.
>>>Map.fromList [("hello",1)] & at "hello" . non 0 +~ 2fromList [("hello",3)]
>>>Map.fromList [("hello",1)] & at "hello" . non 0 -~ 1fromList []
>>>Map.fromList [("hello",1)] ^. at "hello" . non 01
>>>Map.fromList [] ^. at "hello" . non 00
This combinator is also particularly useful when working with nested maps.
e.g. When you want to create the nested Map when it is missing:
>>>Map.empty & at "hello" . non Map.empty . at "world" ?~ "!!!"fromList [("hello",fromList [("world","!!!")])]
and when have deleting the last entry from the nested Map mean that we
should delete its entry from the surrounding one:
>>>fromList [("hello",fromList [("world","!!!")])] & at "hello" . non Map.empty . at "world" .~ NothingfromList []
It can also be used in reverse to exclude a given value:
>>>non 0 # rem 10 4Just 2
>>>non 0 # rem 10 5Nothing
non' :: APrism' a () -> Iso' (Maybe a) a Source #
generalizes non' p to take any unit non (p # ())Prism
This function generates an isomorphism between and Maybe (a | isn't p a)a.
>>>Map.singleton "hello" Map.empty & at "hello" . non' _Empty . at "world" ?~ "!!!"fromList [("hello",fromList [("world","!!!")])]
>>>fromList [("hello",fromList [("world","!!!")])] & at "hello" . non' _Empty . at "world" .~ NothingfromList []
anon :: a -> (a -> Bool) -> Iso' (Maybe a) a Source #
generalizes anon a p to take any value and a predicate.non a
This function assumes that p a holds and generates an isomorphism between True and Maybe (a | not (p a))a.
>>>Map.empty & at "hello" . anon Map.empty Map.null . at "world" ?~ "!!!"fromList [("hello",fromList [("world","!!!")])]
>>>fromList [("hello",fromList [("world","!!!")])] & at "hello" . anon Map.empty Map.null . at "world" .~ NothingfromList []
flipped :: Iso (a -> b -> c) (a' -> b' -> c') (b -> a -> c) (b' -> a' -> c') Source #
The isomorphism for flipping a function.
>>>((,)^.flipped) 1 2(2,1)
lazy :: Strict lazy strict => Iso' strict lazy Source #
An Iso between the strict variant of a structure and its lazy
counterpart.
lazy=fromstrict
See http://hackage.haskell.org/package/strict-base-types for an example use.
reversed :: Reversing a => Iso' a a Source #
An Iso between a list, ByteString, Text fragment, etc. and its reversal.
>>>"live" ^. reversed"evil"
>>>"live" & reversed %~ ('d':)"lived"
dimapping :: (Profunctor p, Profunctor q) => AnIso s t a b -> AnIso s' t' a' b' -> Iso (p a s') (q b t') (p s a') (q t b') Source #
Lift two Isos into both arguments of a Profunctor simultaneously.
dimapping ::Profunctorp =>Isos t a b ->Isos' t' a' b' ->Iso(p a s') (p b t') (p s a') (p t b') dimapping ::Profunctorp =>Iso's a ->Iso's' a' ->Iso'(p a s') (p s a')
lmapping :: (Profunctor p, Profunctor q) => AnIso s t a b -> Iso (p a x) (q b y) (p s x) (q t y) Source #
Lift an Iso contravariantly into the left argument of a Profunctor.
lmapping ::Profunctorp =>Isos t a b ->Iso(p a x) (p b y) (p s x) (p t y) lmapping ::Profunctorp =>Iso's a ->Iso'(p a x) (p s x)
rmapping :: (Profunctor p, Profunctor q) => AnIso s t a b -> Iso (p x s) (q y t) (p x a) (q y b) Source #
Lift an Iso covariantly into the right argument of a Profunctor.
rmapping ::Profunctorp =>Isos t a b ->Iso(p x s) (p y t) (p x a) (p y b) rmapping ::Profunctorp =>Iso's a ->Iso'(p x s) (p x a)
bimapping :: (Bifunctor f, Bifunctor g) => AnIso s t a b -> AnIso s' t' a' b' -> Iso (f s s') (g t t') (f a a') (g b b') Source #
firsting :: (Bifunctor f, Bifunctor g) => AnIso s t a b -> Iso (f s x) (g t y) (f a x) (g b y) Source #
seconding :: (Bifunctor f, Bifunctor g) => AnIso s t a b -> Iso (f x s) (g y t) (f x a) (g y b) Source #
Lift an Iso into the second argument of a Bifunctor. This is
essentially the same as mapping, but it takes a 'Bifunctor p'
constraint instead of a 'Functor (p a)' one.
seconding ::Bifunctorp =>Isos t a b ->Iso(p x s) (p y t) (p x a) (p y b) seconding ::Bifunctorp =>Iso's a ->Iso'(p x s) (p x a)
coerced :: forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b Source #
Data types that are representationally equal are isomorphic.
This is only available on GHC 7.8+
Since: 4.13
class (Rewrapped s t, Rewrapped t s) => Rewrapping s t Source #
Instances
| (Rewrapped s t, Rewrapped t s) => Rewrapping s t Source # | |
Defined in Control.Lens.Wrapped | |
class Wrapped s => Rewrapped (s :: *) (t :: *) Source #
Instances
class Wrapped s where Source #
Wrapped provides isomorphisms to wrap and unwrap newtypes or
data types with one constructor.
Minimal complete definition
Nothing
Methods
_Wrapped' :: Iso' s (Unwrapped s) Source #
An isomorphism between s and a.
If your type has a Generic instance, _Wrapped' will default to _GWrapped',
and you can choose to not override it with your own definition.
_Wrapped' :: (Generic s, D1 d (C1 c (S1 s' (Rec0 a))) ~ Rep s, Unwrapped s ~ GUnwrapped (Rep s)) => Iso' s (Unwrapped s) Source #
An isomorphism between s and a.
If your type has a Generic instance, _Wrapped' will default to _GWrapped',
and you can choose to not override it with your own definition.
Instances
_GWrapped' :: (Generic s, D1 d (C1 c (S1 s' (Rec0 a))) ~ Rep s, Unwrapped s ~ GUnwrapped (Rep s)) => Iso' s (Unwrapped s) Source #
_Wrapped :: Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t) Source #
Work under a newtype wrapper.
>>>Const "hello" & _Wrapped %~ Prelude.length & getConst5
_Wrapped≡from_Unwrapped_Unwrapped≡from_Wrapped
_Unwrapped :: Rewrapping s t => Iso (Unwrapped t) (Unwrapped s) t s Source #
_Wrapping' :: Wrapped s => (Unwrapped s -> s) -> Iso' s (Unwrapped s) Source #
This is a convenient version of _Wrapped with an argument that's ignored.
The user supplied function is ignored, merely its type is used.
_Unwrapping' :: Wrapped s => (Unwrapped s -> s) -> Iso' (Unwrapped s) s Source #
This is a convenient version of _Wrapped with an argument that's ignored.
The user supplied function is ignored, merely its type is used.
_Wrapping :: Rewrapping s t => (Unwrapped s -> s) -> Iso s t (Unwrapped s) (Unwrapped t) Source #
This is a convenient version of _Wrapped with an argument that's ignored.
The user supplied function is ignored, merely its types are used.
_Unwrapping :: Rewrapping s t => (Unwrapped s -> s) -> Iso (Unwrapped t) (Unwrapped s) t s Source #
This is a convenient version of _Unwrapped with an argument that's ignored.
The user supplied function is ignored, merely its types are used.
class Snoc s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
This class provides a way to attach or detach elements on the right side of a structure in a flexible manner.
Methods
Instances
| Snoc [a] [b] a b Source # | |
Defined in Control.Lens.Cons | |
| Snoc (ZipList a) (ZipList b) a b Source # | |
| Snoc (Seq a) (Seq b) a b Source # | |
| (Unbox a, Unbox b) => Snoc (Vector a) (Vector b) a b Source # | |
| (Storable a, Storable b) => Snoc (Vector a) (Vector b) a b Source # | |
| (Prim a, Prim b) => Snoc (Vector a) (Vector b) a b Source # | |
| Snoc (Vector a) (Vector b) a b Source # | |
class Cons s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #
This class provides a way to attach or detach elements on the left side of a structure in a flexible manner.
Methods
Instances
| Cons [a] [b] a b Source # | |
Defined in Control.Lens.Cons | |
| Cons (ZipList a) (ZipList b) a b Source # | |
| Cons (Seq a) (Seq b) a b Source # | |
| (Unbox a, Unbox b) => Cons (Vector a) (Vector b) a b Source # | |
| (Storable a, Storable b) => Cons (Vector a) (Vector b) a b Source # | |
| (Prim a, Prim b) => Cons (Vector a) (Vector b) a b Source # | |
| Cons (Vector a) (Vector b) a b Source # | |
cons :: Cons s s a a => a -> s -> s infixr 5 Source #
cons an element onto a container.
>>>cons a [][a]
>>>cons a [b, c][a,b,c]
>>>cons a (Seq.fromList [])fromList [a]
>>>cons a (Seq.fromList [b, c])fromList [a,b,c]
uncons :: Cons s s a a => s -> Maybe (a, s) Source #
Attempt to extract the left-most element from a container, and a version of the container without that element.
>>>uncons []Nothing
>>>uncons [a, b, c]Just (a,[b,c])
_head :: Cons s s a a => Traversal' s a Source #
A Traversal reading and writing to the head of a non-empty container.
>>>[a,b,c]^? _headJust a
>>>[a,b,c] & _head .~ d[d,b,c]
>>>[a,b,c] & _head %~ f[f a,b,c]
>>>[] & _head %~ f[]
>>>[1,2,3]^?!_head1
>>>[]^?_headNothing
>>>[1,2]^?_headJust 1
>>>[] & _head .~ 1[]
>>>[0] & _head .~ 2[2]
>>>[0,1] & _head .~ 2[2,1]
This isn't limited to lists.
For instance you can also traverse the head of a Seq:
>>>Seq.fromList [a,b,c,d] & _head %~ ffromList [f a,b,c,d]
>>>Seq.fromList [] ^? _headNothing
>>>Seq.fromList [a,b,c,d] ^? _headJust a
_head::Traversal'[a] a_head::Traversal'(Seqa) a_head::Traversal'(Vectora) a
_tail :: Cons s s a a => Traversal' s s Source #
A Traversal reading and writing to the tail of a non-empty container.
>>>[a,b] & _tail .~ [c,d,e][a,c,d,e]
>>>[] & _tail .~ [a,b][]
>>>[a,b,c,d,e] & _tail.traverse %~ f[a,f b,f c,f d,f e]
>>>[1,2] & _tail .~ [3,4,5][1,3,4,5]
>>>[] & _tail .~ [1,2][]
>>>[a,b,c]^?_tailJust [b,c]
>>>[1,2]^?!_tail[2]
>>>"hello"^._tail"ello"
>>>""^._tail""
This isn't limited to lists. For instance you can also traverse the tail of a Seq.
>>>Seq.fromList [a,b] & _tail .~ Seq.fromList [c,d,e]fromList [a,c,d,e]
>>>Seq.fromList [a,b,c] ^? _tailJust (fromList [b,c])
>>>Seq.fromList [] ^? _tailNothing
_tail::Traversal'[a] [a]_tail::Traversal'(Seqa) (Seqa)_tail::Traversal'(Vectora) (Vectora)
_init :: Snoc s s a a => Traversal' s s Source #
A Traversal reading and replacing all but the a last element of a non-empty container.
>>>[a,b,c,d]^?_initJust [a,b,c]
>>>[]^?_initNothing
>>>[a,b] & _init .~ [c,d,e][c,d,e,b]
>>>[] & _init .~ [a,b][]
>>>[a,b,c,d] & _init.traverse %~ f[f a,f b,f c,d]
>>>[1,2,3]^?_initJust [1,2]
>>>[1,2,3,4]^?!_init[1,2,3]
>>>"hello"^._init"hell"
>>>""^._init""
_init::Traversal'[a] [a]_init::Traversal'(Seqa) (Seqa)_init::Traversal'(Vectora) (Vectora)
_last :: Snoc s s a a => Traversal' s a Source #
A Traversal reading and writing to the last element of a non-empty container.
>>>[a,b,c]^?!_lastc
>>>[]^?_lastNothing
>>>[a,b,c] & _last %~ f[a,b,f c]
>>>[1,2]^?_lastJust 2
>>>[] & _last .~ 1[]
>>>[0] & _last .~ 2[2]
>>>[0,1] & _last .~ 2[0,2]
This Traversal is not limited to lists, however. We can also work with other containers, such as a Vector.
>>>Vector.fromList "abcde" ^? _lastJust 'e'
>>>Vector.empty ^? _lastNothing
>>>(Vector.fromList "abcde" & _last .~ 'Q') == Vector.fromList "abcdQ"True
_last::Traversal'[a] a_last::Traversal'(Seqa) a_last::Traversal'(Vectora) a
snoc :: Snoc s s a a => s -> a -> s infixl 5 Source #
snoc an element onto the end of a container.
>>>snoc (Seq.fromList []) afromList [a]
>>>snoc (Seq.fromList [b, c]) afromList [b,c,a]
>>>snoc (LazyT.pack "hello") '!'"hello!"
unsnoc :: Snoc s s a a => s -> Maybe (s, a) Source #
Attempt to extract the right-most element from a container, and a version of the container without that element.
>>>unsnoc (LazyT.pack "hello!")Just ("hello",'!')
>>>unsnoc (LazyT.pack "")Nothing
>>>unsnoc (Seq.fromList [b,c,a])Just (fromList [b,c],a)
>>>unsnoc (Seq.fromList [])Nothing
class AsEmpty a where Source #
Minimal complete definition
Nothing
Methods
_Empty :: Prism' a () Source #
>>>isn't _Empty [1,2,3]True
_Empty :: (Monoid a, Eq a) => Prism' a () Source #
>>>isn't _Empty [1,2,3]True
Instances
| AsEmpty Ordering Source # | |
| AsEmpty () Source # | |
Defined in Control.Lens.Empty | |
| AsEmpty Event Source # | |
| AsEmpty All Source # | |
| AsEmpty Any Source # | |
| AsEmpty IntSet Source # | |
| AsEmpty [a] Source # | |
Defined in Control.Lens.Empty | |
| AsEmpty (Maybe a) Source # | |
| AsEmpty (ZipList a) Source # | |
| AsEmpty (First a) Source # | |
| AsEmpty (Last a) Source # | |
| AsEmpty a => AsEmpty (Dual a) Source # | |
| (Eq a, Num a) => AsEmpty (Sum a) Source # | |
| (Eq a, Num a) => AsEmpty (Product a) Source # | |
| AsEmpty (IntMap a) Source # | |
| AsEmpty (Seq a) Source # | |
| AsEmpty (Set a) Source # | |
| Unbox a => AsEmpty (Vector a) Source # | |
| Storable a => AsEmpty (Vector a) Source # | |
| AsEmpty (Vector a) Source # | |
| (AsEmpty a, AsEmpty b) => AsEmpty (a, b) Source # | |
Defined in Control.Lens.Empty | |
| AsEmpty (Map k a) Source # | |
| (AsEmpty a, AsEmpty b, AsEmpty c) => AsEmpty (a, b, c) Source # | |
Defined in Control.Lens.Empty | |