Safe Haskell | Safe |
---|---|
Language | Haskell98 |
This module contains lenses and traversals for common structures in Haskell. It also contains the combinators for lenses and traversals.
- 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'
- 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')
- beside :: Applicative f => LensLike f a a' c c' -> LensLike f b b' c c' -> LensLike f (a, b) (a', b') c c'
- _1 :: Functor f => LensLike f (a, b) (a', b) a a'
- _2 :: Functor f => LensLike f (a, b) (a, b') b b'
- chosen :: Functor f => LensLike f (Either a a) (Either b b) a b
- ix :: (Eq k, Functor f) => k -> LensLike' f (k -> v) v
- at :: (Ord k, Functor f) => k -> LensLike' f (Map k v) (Maybe v)
- intAt :: Functor f => Int -> LensLike' f (IntMap v) (Maybe v)
- at' :: (Ord k, Functor f) => k -> LensLike' f (Map k v) (Maybe v)
- intAt' :: Functor f => Int -> LensLike' f (IntMap v) (Maybe v)
- contains :: (Ord k, Functor f) => k -> LensLike' f (Set k) Bool
- intContains :: Functor f => Int -> LensLike' f IntSet Bool
- both :: Applicative f => LensLike f (a, a) (b, b) a b
- _Left :: Applicative f => LensLike f (Either a b) (Either a' b) a a'
- _Right :: Applicative f => LensLike f (Either a b) (Either a b') b b'
- _Just :: Applicative f => LensLike f (Maybe a) (Maybe a') a a'
- _Nothing :: Applicative f => LensLike' f (Maybe a) ()
- ignored :: Applicative f => null -> a -> f a
- mapped :: (Identical f, Functor g) => LensLike f (g a) (g a') a a'
- data AlongsideLeft f b a
- data AlongsideRight f a b
- 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
- class Applicative f => Identical f
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' Source #
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') Source #
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' Source #
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 :: Functor f => LensLike f (a, b) (a', b) a a' Source #
_1 :: Lens (a, b) (a', b) a a'
Lens on the first element of a pair.
_2 :: Functor f => LensLike f (a, b) (a, b') b b' Source #
_2 :: Lens (a, b) (a, b') b b'
Lens on the second element of a pair.
chosen :: Functor f => LensLike f (Either a a) (Either b b) a b Source #
chosen :: Lens (Either a a) (Either b b) a b
Lens on the Left or Right element of an (Either
a a).
ix :: (Eq k, Functor f) => k -> LensLike' f (k -> v) v Source #
ix :: Eq k => k -> Lens' (k -> v) v
Lens on a given point of a function.
at :: (Ord k, Functor f) => k -> LensLike' f (Map k v) (Maybe v) Source #
at :: Ord k => k -> Lens' (Map.Map k v) (Maybe v)
Lens on a given point of a Map
.
intAt :: Functor f => Int -> LensLike' f (IntMap v) (Maybe v) Source #
intAt :: Int -> Lens (IntMap.IntMap v) (Maybe v)
Lens on a given point of a IntMap
.
at' :: (Ord k, Functor f) => k -> LensLike' f (Map k v) (Maybe v) Source #
at :: Ord k => k -> Lens' (Map.Map k v) (Maybe v)
Lens providing strict access to a given point of a Map
.
intAt' :: Functor f => Int -> LensLike' f (IntMap v) (Maybe v) Source #
intAt :: Int -> Lens (IntMap.IntMap v) (Maybe v)
Lens providing strict access to a given point of a IntMap
.
contains :: (Ord k, Functor f) => k -> LensLike' f (Set k) Bool Source #
contains :: Ord => k -> Lens' (Set.Set k) Bool
Lens on a given point of a Set
.
intContains :: Functor f => Int -> LensLike' f IntSet Bool Source #
intContains :: Int -> Lens' IntSet.IntSet Bool
Lens on a given point of a IntSet
.
Stock Traversals
both :: Applicative f => LensLike f (a, a) (b, b) a b Source #
both :: Traversal (a,a) (b,b) a b
Traversals on both elements of a pair (a,a)
.
ignored :: Applicative f => null -> a -> f a Source #
ignored :: Traversal a a b b'
The empty traversal on any type.
Stock SECs
mapped :: (Identical f, Functor g) => LensLike f (g a) (g a') a a' Source #
mapped :: Functor g => Setter (g a) (g a') a a'
An SEC referencing the parameter of a functor.
Types
data AlongsideLeft f b a Source #
Functor f => Functor (AlongsideLeft f a) Source # | |
Phantom f => Phantom (AlongsideLeft f a) Source # | |
data AlongsideRight f a b Source #
Functor f => Functor (AlongsideRight f a) Source # | |
Phantom f => Phantom (AlongsideRight f a) Source # | |
Re-exports
class Functor f => Applicative f #
A functor with application, providing operations to
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:
As a consequence of these laws, the Functor
instance for f
will satisfy
If f
is also a Monad
, it should satisfy
(which implies that pure
and <*>
satisfy the applicative functor laws).