lens-family-1.2.1: Lens Families

Lens.Family2.Stock

Description

This module contains lenses and traversals for common structures in Haskell. It also contains the combinators for lenses and traversals.

Synopsis

Lens Combinators

choosing :: Functor f => LensLike f a a' c c' -> LensLike f b b' c c' -> LensLike f (Either a b) (Either a' b') c c' #

choosing :: Lens a a' c c' -> Lens b b' c c' -> Lens (Either a b) (Either a' b') c c'

choosing :: Traversal a a' c c' -> Traversal b b' c c' -> Traversal (Either a b) (Either a' b') c c'

choosing :: Getter a a' c c' -> Getter b b' c c' -> Getter (Either a b) (Either a' b') c c'

choosing :: Fold a a' c c' -> Fold b b' c c' -> Fold (Either a b) (Either a' b') c c'

choosing :: Setter a a' c c' -> Setter b b' c c' -> Setter (Either a b) (Either a' b') c c'


Given two lens/traversal/getter/fold/setter families with the same substructure, make a new lens/traversal/getter/fold/setter on Either.

alongside :: Functor f => LensLike (AlongsideLeft f b2') a1 a1' b1 b1' -> LensLike (AlongsideRight f a1') a2 a2' b2 b2' -> LensLike f (a1, a2) (a1', a2') (b1, b2) (b1', b2') #

alongside :: Lens a1 a1' b1 b1' -> Lens a2 a2' b2 b2' -> Lens (a1, a2) (a1', a2') (b1, b2) (b1', b2')

alongside :: Getter a1 a1' b1 b1' -> Getter a2 a2' b2 b2' -> Getter (a1, a2) (a1', a2') (b1, b2) (b1', b2')


Given two lens/getter families, make a new lens/getter on their product.

beside :: Applicative f => LensLike f a a' c c' -> LensLike f b b' c c' -> LensLike f (a, b) (a', b') c c' #

beside :: Traversal a a' c c' -> Traversal b' b' c c' -> Traversal (a,b) (a',b') c c'

beside :: Fold a a' c c' -> Fold b' b' c c' -> Fold (a,b) (a',b') c c'

beside :: Setter a a' c c' -> Setter b' b' c c' -> Setter (a,b) (a',b') c c'


Given two traversals/folds/setters referencing a type c, create a traversal/fold/setter on the pair referencing c.

Stock Lenses

_1 :: Lens (a, b) (a', b) a a' Source #

Lens on the first element of a pair.

_2 :: Lens (a, b) (a, b') b b' Source #

Lens on the second element of a pair.

chosen :: Lens (Either a a) (Either b b) a b Source #

Lens on the Left or Right element of an (Either a a).

ix :: Eq k => k -> Lens' (k -> v) v Source #

Lens on a given point of a function.

at :: Ord k => k -> Lens' (Map k v) (Maybe v) Source #

Lens on a given point of a Map.

intAt :: Int -> Lens' (IntMap v) (Maybe v) Source #

Lens on a given point of a IntMap.

contains :: Ord k => k -> Lens' (Set k) Bool Source #

Lens on a given point of a Set.

Lens on a given point of a IntSet.

Stock Traversals

both :: Traversal (a, a) (b, b) a b Source #

Traversals on both elements of a pair (a,a).

_Left :: Traversal (Either a b) (Either a' b) a a' Source #

Traversal on the Left element of an Either.

_Right :: Traversal (Either a b) (Either a b') b b' Source #

Traversal on the Right element of an Either.

_Just :: Traversal (Maybe a) (Maybe a') a a' Source #

Traversal on the Just element of a Maybe.

_Nothing :: Traversal' (Maybe a) () Source #

Traversal on the Nothing element of a Maybe.

ignored :: Traversal a a b b' Source #

The empty traveral on any type.

Stock SECs

mapped :: Functor f => Setter (f a) (f a') a a' Source #

An SEC referencing the parameter of a functor.

Types

data AlongsideLeft f b a :: (* -> *) -> * -> * -> * #

Instances

 Functor f => Functor (AlongsideLeft f a) Methodsfmap :: (a -> b) -> AlongsideLeft f a a -> AlongsideLeft f a b #(<$) :: a -> AlongsideLeft f a b -> AlongsideLeft f a a # Phantom f => Phantom (AlongsideLeft f a) Methodscoerce :: AlongsideLeft f a a -> AlongsideLeft f a b data AlongsideRight f a b :: (* -> *) -> * -> * -> * # Instances  Functor f => Functor (AlongsideRight f a) Methodsfmap :: (a -> b) -> AlongsideRight f a a -> AlongsideRight f a b #(<$) :: a -> AlongsideRight f a b -> AlongsideRight f a a # Phantom f => Phantom (AlongsideRight f a) Methodscoerce :: AlongsideRight f a a -> AlongsideRight f a b

Re-exports

type Lens a a' b b' = forall f. Functor f => LensLike f a a' b b' Source #

type Lens' a b = forall f. Functor f => LensLike' f a b Source #

type Traversal a a' b b' = forall f. Applicative f => LensLike f a a' b b' Source #

type Traversal' a b = forall f. Applicative f => LensLike' f a b Source #

type Setter a a' b b' = forall f. Identical f => LensLike f a a' b b' Source #

type LensLike f a a' b b' = (b -> f b') -> a -> f a' #

type LensLike' f a b = (b -> f b) -> a -> f a #

class Functor f => Applicative f #

A functor with application, providing operations to

• embed pure expressions (pure), and
• sequence computations and combine their results (<*>).

A minimal complete definition must include implementations of these functions satisfying the following laws:

identity
pure id <*> v = v
composition
pure (.) <*> u <*> v <*> w = u <*> (v <*> w)
homomorphism
pure f <*> pure x = pure (f x)
interchange
u <*> pure y = pure (\$ y) <*> u

The other methods have the following default definitions, which may be overridden with equivalent specialized implementations:

• u *> v = pure (const id) <*> u <*> v
• u <* v = pure const <*> u <*> v

As a consequence of these laws, the Functor instance for f will satisfy

• fmap f x = pure f <*> x

If f is also a Monad, it should satisfy

• pure = return
• (<*>) = ap

(which implies that pure and <*> satisfy the applicative functor laws).

Minimal complete definition

Instances

 Methodspure :: a -> [a] #(<*>) :: [a -> b] -> [a] -> [b] #(*>) :: [a] -> [b] -> [b] #(<*) :: [a] -> [b] -> [a] # Methodspure :: a -> Maybe a #(<*>) :: Maybe (a -> b) -> Maybe a -> Maybe b #(*>) :: Maybe a -> Maybe b -> Maybe b #(<*) :: Maybe a -> Maybe b -> Maybe a # Methodspure :: a -> IO a #(<*>) :: IO (a -> b) -> IO a -> IO b #(*>) :: IO a -> IO b -> IO b #(<*) :: IO a -> IO b -> IO a # Methodspure :: a -> U1 a #(<*>) :: U1 (a -> b) -> U1 a -> U1 b #(*>) :: U1 a -> U1 b -> U1 b #(<*) :: U1 a -> U1 b -> U1 a # Methodspure :: a -> Par1 a #(<*>) :: Par1 (a -> b) -> Par1 a -> Par1 b #(*>) :: Par1 a -> Par1 b -> Par1 b #(<*) :: Par1 a -> Par1 b -> Par1 a # Methodspure :: a -> Identity a #(<*>) :: Identity (a -> b) -> Identity a -> Identity b #(*>) :: Identity a -> Identity b -> Identity b #(<*) :: Identity a -> Identity b -> Identity a # Methodspure :: a -> ZipList a #(<*>) :: ZipList (a -> b) -> ZipList a -> ZipList b #(*>) :: ZipList a -> ZipList b -> ZipList b #(<*) :: ZipList a -> ZipList b -> ZipList a # Methodspure :: a -> Dual a #(<*>) :: Dual (a -> b) -> Dual a -> Dual b #(*>) :: Dual a -> Dual b -> Dual b #(<*) :: Dual a -> Dual b -> Dual a # Methodspure :: a -> Sum a #(<*>) :: Sum (a -> b) -> Sum a -> Sum b #(*>) :: Sum a -> Sum b -> Sum b #(<*) :: Sum a -> Sum b -> Sum a # Methodspure :: a -> Product a #(<*>) :: Product (a -> b) -> Product a -> Product b #(*>) :: Product a -> Product b -> Product b #(<*) :: Product a -> Product b -> Product a # Methodspure :: a -> First a #(<*>) :: First (a -> b) -> First a -> First b #(*>) :: First a -> First b -> First b #(<*) :: First a -> First b -> First a # Methodspure :: a -> Last a #(<*>) :: Last (a -> b) -> Last a -> Last b #(*>) :: Last a -> Last b -> Last b #(<*) :: Last a -> Last b -> Last a # Applicative ((->) a) Methodspure :: a -> a -> a #(<*>) :: (a -> a -> b) -> (a -> a) -> a -> b #(*>) :: (a -> a) -> (a -> b) -> a -> b #(<*) :: (a -> a) -> (a -> b) -> a -> a # Methodspure :: a -> Either e a #(<*>) :: Either e (a -> b) -> Either e a -> Either e b #(*>) :: Either e a -> Either e b -> Either e b #(<*) :: Either e a -> Either e b -> Either e a # Applicative f => Applicative (Rec1 f) Methodspure :: a -> Rec1 f a #(<*>) :: Rec1 f (a -> b) -> Rec1 f a -> Rec1 f b #(*>) :: Rec1 f a -> Rec1 f b -> Rec1 f b #(<*) :: Rec1 f a -> Rec1 f b -> Rec1 f a # Monoid a => Applicative ((,) a) Methodspure :: a -> (a, a) #(<*>) :: (a, a -> b) -> (a, a) -> (a, b) #(*>) :: (a, a) -> (a, b) -> (a, b) #(<*) :: (a, a) -> (a, b) -> (a, a) # Monad m => Applicative (WrappedMonad m) Methodspure :: a -> WrappedMonad m a #(<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b #(*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b #(<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a # Arrow a => Applicative (ArrowMonad a) Methodspure :: a -> ArrowMonad a a #(<*>) :: ArrowMonad a (a -> b) -> ArrowMonad a a -> ArrowMonad a b #(*>) :: ArrowMonad a a -> ArrowMonad a b -> ArrowMonad a b #(<*) :: ArrowMonad a a -> ArrowMonad a b -> ArrowMonad a a # Methodspure :: a -> Proxy * a #(<*>) :: Proxy * (a -> b) -> Proxy * a -> Proxy * b #(*>) :: Proxy * a -> Proxy * b -> Proxy * b #(<*) :: Proxy * a -> Proxy * b -> Proxy * a # Applicative m => Applicative (ListT m) Methodspure :: a -> ListT m a #(<*>) :: ListT m (a -> b) -> ListT m a -> ListT m b #(*>) :: ListT m a -> ListT m b -> ListT m b #(<*) :: ListT m a -> ListT m b -> ListT m a # (Functor m, Monad m) => Applicative (MaybeT m) Methodspure :: a -> MaybeT m a #(<*>) :: MaybeT m (a -> b) -> MaybeT m a -> MaybeT m b #(*>) :: MaybeT m a -> MaybeT m b -> MaybeT m b #(<*) :: MaybeT m a -> MaybeT m b -> MaybeT m a # (Applicative f, Applicative g) => Applicative ((:*:) f g) Methodspure :: a -> (f :*: g) a #(<*>) :: (f :*: g) (a -> b) -> (f :*: g) a -> (f :*: g) b #(*>) :: (f :*: g) a -> (f :*: g) b -> (f :*: g) b #(<*) :: (f :*: g) a -> (f :*: g) b -> (f :*: g) a # (Applicative f, Applicative g) => Applicative ((:.:) f g) Methodspure :: a -> (f :.: g) a #(<*>) :: (f :.: g) (a -> b) -> (f :.: g) a -> (f :.: g) b #(*>) :: (f :.: g) a -> (f :.: g) b -> (f :.: g) b #(<*) :: (f :.: g) a -> (f :.: g) b -> (f :.: g) a # Arrow a => Applicative (WrappedArrow a b) Methodspure :: a -> WrappedArrow a b a #(<*>) :: WrappedArrow a b (a -> b) -> WrappedArrow a b a -> WrappedArrow a b b #(*>) :: WrappedArrow a b a -> WrappedArrow a b b -> WrappedArrow a b b #(<*) :: WrappedArrow a b a -> WrappedArrow a b b -> WrappedArrow a b a # Monoid m => Applicative (Const * m) Methodspure :: a -> Const * m a #(<*>) :: Const * m (a -> b) -> Const * m a -> Const * m b #(*>) :: Const * m a -> Const * m b -> Const * m b #(<*) :: Const * m a -> Const * m b -> Const * m a # Applicative f => Applicative (Alt * f) Methodspure :: a -> Alt * f a #(<*>) :: Alt * f (a -> b) -> Alt * f a -> Alt * f b #(*>) :: Alt * f a -> Alt * f b -> Alt * f b #(<*) :: Alt * f a -> Alt * f b -> Alt * f a # (Monoid c, Monad m) => Applicative (Zooming m c) Methodspure :: a -> Zooming m c a #(<*>) :: Zooming m c (a -> b) -> Zooming m c a -> Zooming m c b #(*>) :: Zooming m c a -> Zooming m c b -> Zooming m c b #(<*) :: Zooming m c a -> Zooming m c b -> Zooming m c a # Monoid a => Applicative (Constant * a) Methodspure :: a -> Constant * a a #(<*>) :: Constant * a (a -> b) -> Constant * a a -> Constant * a b #(*>) :: Constant * a a -> Constant * a b -> Constant * a b #(<*) :: Constant * a a -> Constant * a b -> Constant * a a # (Functor m, Monad m) => Applicative (StateT s m) Methodspure :: a -> StateT s m a #(<*>) :: StateT s m (a -> b) -> StateT s m a -> StateT s m b #(*>) :: StateT s m a -> StateT s m b -> StateT s m b #(<*) :: StateT s m a -> StateT s m b -> StateT s m a # (Functor m, Monad m) => Applicative (StateT s m) Methodspure :: a -> StateT s m a #(<*>) :: StateT s m (a -> b) -> StateT s m a -> StateT s m b #(*>) :: StateT s m a -> StateT s m b -> StateT s m b #(<*) :: StateT s m a -> StateT s m b -> StateT s m a # Apply f-actions in the reverse order. Methodspure :: a -> Backwards * f a #(<*>) :: Backwards * f (a -> b) -> Backwards * f a -> Backwards * f b #(*>) :: Backwards * f a -> Backwards * f b -> Backwards * f b #(<*) :: Backwards * f a -> Backwards * f b -> Backwards * f a # (Functor m, Monad m) => Applicative (ExceptT e m) Methodspure :: a -> ExceptT e m a #(<*>) :: ExceptT e m (a -> b) -> ExceptT e m a -> ExceptT e m b #(*>) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m b #(<*) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m a # (Functor m, Monad m) => Applicative (ErrorT e m) Methodspure :: a -> ErrorT e m a #(<*>) :: ErrorT e m (a -> b) -> ErrorT e m a -> ErrorT e m b #(*>) :: ErrorT e m a -> ErrorT e m b -> ErrorT e m b #(<*) :: ErrorT e m a -> ErrorT e m b -> ErrorT e m a # (Monoid w, Applicative m) => Applicative (WriterT w m) Methodspure :: a -> WriterT w m a #(<*>) :: WriterT w m (a -> b) -> WriterT w m a -> WriterT w m b #(*>) :: WriterT w m a -> WriterT w m b -> WriterT w m b #(<*) :: WriterT w m a -> WriterT w m b -> WriterT w m a # (Monoid w, Applicative m) => Applicative (WriterT w m) Methodspure :: a -> WriterT w m a #(<*>) :: WriterT w m (a -> b) -> WriterT w m a -> WriterT w m b #(*>) :: WriterT w m a -> WriterT w m b -> WriterT w m b #(<*) :: WriterT w m a -> WriterT w m b -> WriterT w m a # Methodspure :: a -> IdentityT * m a #(<*>) :: IdentityT * m (a -> b) -> IdentityT * m a -> IdentityT * m b #(*>) :: IdentityT * m a -> IdentityT * m b -> IdentityT * m b #(<*) :: IdentityT * m a -> IdentityT * m b -> IdentityT * m a # Applicative f => Applicative (M1 i c f) Methodspure :: a -> M1 i c f a #(<*>) :: M1 i c f (a -> b) -> M1 i c f a -> M1 i c f b #(*>) :: M1 i c f a -> M1 i c f b -> M1 i c f b #(<*) :: M1 i c f a -> M1 i c f b -> M1 i c f a # Applicative (ContT k r m) Methodspure :: a -> ContT k r m a #(<*>) :: ContT k r m (a -> b) -> ContT k r m a -> ContT k r m b #(*>) :: ContT k r m a -> ContT k r m b -> ContT k r m b #(<*) :: ContT k r m a -> ContT k r m b -> ContT k r m a # Applicative m => Applicative (ReaderT * r m) Methodspure :: a -> ReaderT * r m a #(<*>) :: ReaderT * r m (a -> b) -> ReaderT * r m a -> ReaderT * r m b #(*>) :: ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m b #(<*) :: ReaderT * r m a -> ReaderT * r m b -> ReaderT * r m a # (Applicative f, Applicative g) => Applicative (Compose * * f g) Methodspure :: a -> Compose * * f g a #(<*>) :: Compose * * f g (a -> b) -> Compose * * f g a -> Compose * * f g b #(*>) :: Compose * * f g a -> Compose * * f g b -> Compose * * f g b #(<*) :: Compose * * f g a -> Compose * * f g b -> Compose * * f g a # (Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) Methodspure :: a -> RWST r w s m a #(<*>) :: RWST r w s m (a -> b) -> RWST r w s m a -> RWST r w s m b #(*>) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m b #(<*) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m a # (Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) Methodspure :: a -> RWST r w s m a #(<*>) :: RWST r w s m (a -> b) -> RWST r w s m a -> RWST r w s m b #(*>) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m b #(<*) :: RWST r w s m a -> RWST r w s m b -> RWST r w s m a #

class Applicative f => Identical f #

Minimal complete definition

extract

Instances

 Methodsextract :: Identity a -> a Identical f => Identical (Backwards * f) Methodsextract :: Backwards * f a -> a (Identical f, Identical g) => Identical (Compose * * f g) Methodsextract :: Compose * * f g a -> a