lens-family-2.0.0: Lens Families

Lens.Family2.Stock

Description

This module contains lenses, prisms, grids, grates and traversals for common structures in Haskell. It also contains the combinators for various kinds of optics.

A Function name with ' is a grate variant of a grid, and a function name with _ is a traversal variants of a grid or prism. For example, both' is the grate variant of both while both_ is the traversal variant.

Synopsis

# Stock Lenses

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

Lens on the first element of a pair.

_2 :: Lens (r, a) (r, b) a 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.

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

Lens providing strict access to a given point of a Map.

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

Lens providing strict access to 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 Prisms

lft :: Prism (Either a r) (Either b r) a b Source #

A prism on the Left element of an Either.

rgt :: Prism (Either r a) (Either r b) a b Source #

A prism on the Right element of an Either.

some :: Prism (Maybe a) (Maybe b) a b Source #

A prism on the Just element of a Maybe.

none :: Prism' (Maybe a) () Source #

A prism on the Nothing element of a Maybe.

# Stock Grids

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

A grid on both elements of a pair (a,a).

A grid from the most significant bit to the least significant bit of a FiniteBits type.

Big endian order.

A grid from the least significant bit to the most significant bit of a FiniteBits type.

Little endian order.

# Stock Grates

cod :: Grate (r -> a) (r -> b) a b Source #

A grate accessing the codomain of a function.

both' :: Grate (a, a) (b, b) a b Source #

A grate on both elements of a pair (a,a).

A grate from the most significant bit to the least significant bit of a FiniteBits type.

Big endian order.

A grate from the least significant bit to the most significant bit of a FiniteBits type.

Little endian order.

# Stock Traversals

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

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

A traversal from the most significant bit to the least significant bit of a FiniteBits type.

Big endian order.

A traversal from the least significant bit to the most significant bit of a FiniteBits type.

Little endian order.

lft_ :: Traversal (Either a r) (Either b r) a b Source #

Traversal on the Left element of an Either.

rgt_ :: Traversal (Either r a) (Either r b) a b Source #

Traversal on the Right element of an Either.

some_ :: Traversal (Maybe a) (Maybe b) a b Source #

Traversal on the Just element of a Maybe.

none_ :: 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.

# Lens Combinators

alongside :: Functor f => LensLike (AlongsideLeft f b1) s0 t0 a0 b0 -> LensLike (AlongsideRight f t0) s1 t1 a1 b1 -> LensLike f (s0, s1) (t0, t1) (a0, a1) (b0, b1) #

alongside :: Lens s0 t0 a0 b0 -> Lens s1 t1 a1 b1 -> Lens (s0, s1) (t0, t1) (a0, a1) (b0, b1)

alongside :: Getter s0 t0 a0 b0 -> Getter s1 t1 a1 b1 -> Getter (s0, s1) (t0, t1) (a0, a1) (b0, b1)


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

backwards :: LensLike (Backwards f) s t a b -> LensLike f s t a b #

backwards :: Traversal s t a b -> Traversal s t a b
backwards :: Fold s t a b -> Fold s t a b


Given a traversal or fold, reverse the order that elements are traversed.

backwards :: Lens s t a b -> Lens s t a b
backwards :: Getter s t a b -> Getter s t a b
backwards :: Setter s t a b -> Setter s t a b


No effect on lenses, getters or setters.

beside :: (Applicative f, Functor g) => AdapterLike f g s0 t0 a b -> AdapterLike f g s1 t1 a b -> AdapterLike f g (s0, s1) (t0, t1) a b #

beside :: Grid s1 t1 a b -> Grid s2 t2 a b -> Grid (s1, s2) (t1, t2) a b


Given two grids referencing a type c, create a grid on the pair referencing c.

beside' :: Functor g => GrateLike g s0 t0 a b -> GrateLike g s1 t1 a b -> GrateLike g (s0, s1) (t0, t1) a b #

beside' :: Grate s0 t0 a b -> Grate s1 t1 a b -> Grate (s0, s1) (t0, t1) a b

beside' :: Resetter s0 t0 a b -> Resetter s1 t1 a b -> Resetter (s0, s1) (t0, t1) a b


Given two grates/resetters referencing a type c, create a grate/resetter on the pair referencing c.

beside_ :: Applicative f => LensLike f s0 t0 a b -> LensLike f s1 t1 a b -> LensLike f (s0, s1) (t0, t1) a b #

beside_ :: Traversal s0 t0 a b -> Traversal s1 t1 a b -> Traversal (s0, s1) (t0, t1) a b

beside_ :: Fold s0 t0 a b -> Fold s1 t1 a b -> Fold (s0, s1) (t0, t1) a b

beside_ :: Setter s0 t0 a b -> Setter s1 t1 a b -> Setter (s0, s1) (t0, t1) a b


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

choosing :: Functor f => LensLike f s0 t0 a b -> LensLike f s1 t1 a b -> LensLike f (Either s0 s1) (Either t0 t1) a b #

choosing :: Lens s0 t0 a b -> Lens s1 t1 a b -> Lens (Either s0 s1) (Either t0 t1) a b

choosing :: Traversal s0 t0 a b -> Traversal s1 t1 a b -> Traversal (Either s0 s1) (Either t0 t1) a b

choosing :: Getter s0 t0 a b -> Getter s1 t1 a b -> Getter (Either s0 s1) (Either t0 t1) a b

choosing :: Fold s0 t0 a b -> Fold s1 t1 a b -> Fold (Either s0 s1) (Either t0 t1) a b

choosing :: Setter s0 t0 a b -> Setter s1 t1 a b -> Setter (Either s0 s1) (Either t0 t1) a b


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

from :: (Functor f, Functor g) => AdapterLike (FromF (g s -> f t) (f b) g) (FromG (f b) f) b a t s -> AdapterLike f g s t a b #

from :: Adapter b a t s -> Adapter s t a b


Reverses the direction of an adapter.

from :: Getter b a t s -> Reviewer s t a b
from :: Reviewer b a t s -> Getter s t a b


Changes a Getter into a Reviewer and vice versa.

# Types

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

Instances
 Functor f => Functor (AlongsideLeft f a) Instance detailsDefined in Lens.Family.Stock Methodsfmap :: (a0 -> b) -> AlongsideLeft f a a0 -> AlongsideLeft f a b #(<$) :: a0 -> AlongsideLeft f a b -> AlongsideLeft f a a0 # Phantom f => Phantom (AlongsideLeft f a) Instance detailsDefined in Lens.Family.Stock Methodscoerce :: AlongsideLeft f a a0 -> AlongsideLeft f a b data AlongsideRight (f :: Type -> Type) a b # Instances  Functor f => Functor (AlongsideRight f a) Instance detailsDefined in Lens.Family.Stock Methodsfmap :: (a0 -> b) -> AlongsideRight f a a0 -> AlongsideRight f a b #(<$) :: a0 -> AlongsideRight f a b -> AlongsideRight f a a0 # Phantom f => Phantom (AlongsideRight f a) Instance detailsDefined in Lens.Family.Stock Methodscoerce :: AlongsideRight f a a0 -> AlongsideRight f a b

data FromF i j (g :: Type -> Type) x #

Instances
 Functor g => Functor (FromF i j g) Instance detailsDefined in Lens.Family.Stock Methodsfmap :: (a -> b) -> FromF i j g a -> FromF i j g b #(<$) :: a -> FromF i j g b -> FromF i j g a # Phantom g => Phantom (FromF i j g) Instance detailsDefined in Lens.Family.Stock Methodscoerce :: FromF i j g a -> FromF i j g b data FromG e (f :: Type -> Type) x # Instances  Functor f => Functor (FromG e f) Instance detailsDefined in Lens.Family.Stock Methodsfmap :: (a -> b) -> FromG e f a -> FromG e f b #(<$) :: a -> FromG e f b -> FromG e f a # Phantom g => Phantom (FromG e g) Instance detailsDefined in Lens.Family.Stock Methodscoerce :: FromG e g a -> FromG e g b

# Re-exports

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

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

type Grate s t a b = forall g. Functor g => GrateLike g s t a b Source #

type Grate' s a = forall g. Functor g => GrateLike' g s a Source #

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

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

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

type AdapterLike (f :: Type -> Type) (g :: Type -> Type) s t a b = (g a -> f b) -> g s -> f t #

type AdapterLike' (f :: Type -> Type) (g :: Type -> Type) s a = (g a -> f a) -> g s -> f s #

type LensLike (f :: Type -> Type) s t a b = (a -> f b) -> s -> f t #

type LensLike' (f :: Type -> Type) s a = (a -> f a) -> s -> f s #

class (Traversable f, Applicative f) => Identical (f :: Type -> Type) #

Minimal complete definition

extract

Instances
 Instance detailsDefined in Lens.Family.Identical Methodsextract :: Identity a -> a Identical f => Identical (Backwards f) Instance detailsDefined in Lens.Family.Identical Methodsextract :: Backwards f a -> a (Identical f, Identical g) => Identical (Compose f g) Instance detailsDefined in Lens.Family.Identical Methodsextract :: Compose f g a -> a

data Backwards (f :: k -> Type) (a :: k) :: forall k. (k -> Type) -> k -> Type #

The same functor, but with an Applicative instance that performs actions in the reverse order.

Instances
 Functor f => Functor (Backwards f) Derived instance. Instance detailsDefined in Control.Applicative.Backwards Methodsfmap :: (a -> b) -> Backwards f a -> Backwards f b #(<$) :: a -> Backwards f b -> Backwards f a # Apply f-actions in the reverse order. Instance detailsDefined in Control.Applicative.Backwards Methodspure :: a -> Backwards f a #(<*>) :: Backwards f (a -> b) -> Backwards f a -> Backwards f b #liftA2 :: (a -> b -> c) -> Backwards f a -> Backwards f b -> Backwards f c #(*>) :: Backwards f a -> Backwards f b -> Backwards f b #(<*) :: Backwards f a -> Backwards f b -> Backwards f a # Foldable f => Foldable (Backwards f) Derived instance. Instance detailsDefined in Control.Applicative.Backwards Methodsfold :: Monoid m => Backwards f m -> m #foldMap :: Monoid m => (a -> m) -> Backwards f a -> m #foldr :: (a -> b -> b) -> b -> Backwards f a -> b #foldr' :: (a -> b -> b) -> b -> Backwards f a -> b #foldl :: (b -> a -> b) -> b -> Backwards f a -> b #foldl' :: (b -> a -> b) -> b -> Backwards f a -> b #foldr1 :: (a -> a -> a) -> Backwards f a -> a #foldl1 :: (a -> a -> a) -> Backwards f a -> a #toList :: Backwards f a -> [a] #null :: Backwards f a -> Bool #length :: Backwards f a -> Int #elem :: Eq a => a -> Backwards f a -> Bool #maximum :: Ord a => Backwards f a -> a #minimum :: Ord a => Backwards f a -> a #sum :: Num a => Backwards f a -> a #product :: Num a => Backwards f a -> a # Derived instance. Instance detailsDefined in Control.Applicative.Backwards Methodstraverse :: Applicative f0 => (a -> f0 b) -> Backwards f a -> f0 (Backwards f b) #sequenceA :: Applicative f0 => Backwards f (f0 a) -> f0 (Backwards f a) #mapM :: Monad m => (a -> m b) -> Backwards f a -> m (Backwards f b) #sequence :: Monad m => Backwards f (m a) -> m (Backwards f a) # Derived instance. Instance detailsDefined in Control.Applicative.Backwards Methodscontramap :: (a -> b) -> Backwards f b -> Backwards f a #(>$) :: b -> Backwards f b -> Backwards f a # Eq1 f => Eq1 (Backwards f) Instance detailsDefined in Control.Applicative.Backwards MethodsliftEq :: (a -> b -> Bool) -> Backwards f a -> Backwards f b -> Bool # Ord1 f => Ord1 (Backwards f) Instance detailsDefined in Control.Applicative.Backwards MethodsliftCompare :: (a -> b -> Ordering) -> Backwards f a -> Backwards f b -> Ordering # Read1 f => Read1 (Backwards f) Instance detailsDefined in Control.Applicative.Backwards MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Backwards f a) #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Backwards f a] #liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Backwards f a) #liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Backwards f a] # Show1 f => Show1 (Backwards f) Instance detailsDefined in Control.Applicative.Backwards MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Backwards f a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Backwards f a] -> ShowS # Try alternatives in the same order as f. Instance detailsDefined in Control.Applicative.Backwards Methodsempty :: Backwards f a #(<|>) :: Backwards f a -> Backwards f a -> Backwards f a #some :: Backwards f a -> Backwards f [a] #many :: Backwards f a -> Backwards f [a] # Phantom f => Phantom (Backwards f) Instance detailsDefined in Lens.Family.Phantom Methodscoerce :: Backwards f a -> Backwards f b Identical f => Identical (Backwards f) Instance detailsDefined in Lens.Family.Identical Methodsextract :: Backwards f a -> a (Eq1 f, Eq a) => Eq (Backwards f a) Instance detailsDefined in Control.Applicative.Backwards Methods(==) :: Backwards f a -> Backwards f a -> Bool #(/=) :: Backwards f a -> Backwards f a -> Bool # (Ord1 f, Ord a) => Ord (Backwards f a) Instance detailsDefined in Control.Applicative.Backwards Methodscompare :: Backwards f a -> Backwards f a -> Ordering #(<) :: Backwards f a -> Backwards f a -> Bool #(<=) :: Backwards f a -> Backwards f a -> Bool #(>) :: Backwards f a -> Backwards f a -> Bool #(>=) :: Backwards f a -> Backwards f a -> Bool #max :: Backwards f a -> Backwards f a -> Backwards f a #min :: Backwards f a -> Backwards f a -> Backwards f a # (Read1 f, Read a) => Read (Backwards f a) Instance detailsDefined in Control.Applicative.Backwards MethodsreadsPrec :: Int -> ReadS (Backwards f a) #readList :: ReadS [Backwards f a] #readPrec :: ReadPrec (Backwards f a) # (Show1 f, Show a) => Show (Backwards f a) Instance detailsDefined in Control.Applicative.Backwards MethodsshowsPrec :: Int -> Backwards f a -> ShowS #show :: Backwards f a -> String #showList :: [Backwards f a] -> ShowS #

class Bits b => FiniteBits b #

The FiniteBits class denotes types with a finite, fixed number of bits.

Since: base-4.7.0.0

Minimal complete definition

finiteBitSize

Instances
 Since: base-4.7.0.0 Instance detailsDefined in Data.Bits Methods Since: base-4.6.0.0 Instance detailsDefined in Data.Bits Methods Since: base-4.6.0.0 Instance detailsDefined in Data.Bits Methods FiniteBits a => FiniteBits (Identity a) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Identity Methods FiniteBits a => FiniteBits (Const a b) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Const MethodsfiniteBitSize :: Const a b -> Int #countLeadingZeros :: Const a b -> Int #countTrailingZeros :: Const a b -> Int #