module Lens.Family.Stock (
_1, _2
, chosen
, ix
, at, intAt
, at', intAt'
, contains, intContains
, left, right
, just, nothing
, both
, bend, lend
, cod
, both'
, bend', lend'
, both_
, bend_, lend_
, left_, right_
, just_, nothing_
, ignored
, mapped
, alongside
, backwards
, beside, beside', beside_
, choosing
, from
, AlongsideLeft, AlongsideRight
, FromF, FromG
, AdapterLike, AdapterLike'
, LensLike, LensLike'
, GrateLike, GrateLike'
, Identical, Backwards
, FiniteBits
, lft, rgt
, some, none
, lft_, rgt_
, some_, none_
) where
import Control.Arrow (first, second)
import Control.Applicative.Backwards (Backwards(..))
import Control.Applicative (liftA2)
import Data.Bits (FiniteBits, (.|.), bit, finiteBitSize, testBit, zeroBits)
import qualified Data.IntMap as IntMap
import qualified Data.IntMap.Strict as IntMap'
import qualified Data.IntSet as IntSet
import qualified Data.Map as Map
import qualified Data.Map.Strict as Map'
import Data.Proxy (asProxyTypeOf)
import qualified Data.Set as Set
import Lens.Family
import Lens.Family.Phantom
import Lens.Family.Unchecked
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 :: LensLike f s0 t0 a b
-> LensLike f s1 t1 a b
-> LensLike f (Either s0 s1) (Either t0 t1) a b
choosing LensLike f s0 t0 a b
la LensLike f s1 t1 a b
_ a -> f b
f (Left s0
a) = t0 -> Either t0 t1
forall a b. a -> Either a b
Left (t0 -> Either t0 t1) -> f t0 -> f (Either t0 t1)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LensLike f s0 t0 a b
la a -> f b
f s0
a
choosing LensLike f s0 t0 a b
_ LensLike f s1 t1 a b
lb a -> f b
f (Right s1
b) = t1 -> Either t0 t1
forall a b. b -> Either a b
Right (t1 -> Either t0 t1) -> f t1 -> f (Either t0 t1)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LensLike f s1 t1 a b
lb a -> f b
f s1
b
_1 :: Functor f => LensLike f (a, r) (b, r) a b
_1 :: LensLike f (a, r) (b, r) a b
_1 a -> f b
f (a
a, r
r) = (\b
b -> (b
b, r
r)) (b -> (b, r)) -> f b -> f (b, r)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a
_2 :: Functor f => LensLike f (r, a) (r, b) a b
_2 :: LensLike f (r, a) (r, b) a b
_2 a -> f b
f (r
r, a
a) = (\b
b -> (r
r, b
b)) (b -> (r, b)) -> f b -> f (r, b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a
chosen :: Functor f => LensLike f (Either a a) (Either b b) a b
chosen :: LensLike f (Either a a) (Either b b) a b
chosen = LensLike f a b a b
-> LensLike f a b a b -> LensLike f (Either a a) (Either b b) a b
forall (f :: * -> *) s0 t0 a b s1 t1.
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 LensLike f a b a b
forall a. a -> a
id LensLike f a b a b
forall a. a -> a
id
ix :: (Eq k, Functor f) => k -> LensLike' f (k -> v) v
ix :: k -> LensLike' f (k -> v) v
ix k
k v -> f v
f k -> v
g = (\v
v' k
x -> if (k
k k -> k -> Bool
forall a. Eq a => a -> a -> Bool
== k
x) then v
v' else k -> v
g k
x) (v -> k -> v) -> f v -> f (k -> v)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> v -> f v
f (k -> v
g k
k)
at :: (Ord k, Functor f) => k -> LensLike' f (Map.Map k v) (Maybe v)
at :: k -> LensLike' f (Map k v) (Maybe v)
at = ((Maybe v -> f (Maybe v)) -> k -> Map k v -> f (Map k v))
-> k -> LensLike' f (Map k v) (Maybe v)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Maybe v -> f (Maybe v)) -> k -> Map k v -> f (Map k v)
forall (f :: * -> *) k a.
(Functor f, Ord k) =>
(Maybe a -> f (Maybe a)) -> k -> Map k a -> f (Map k a)
Map.alterF
intAt :: Functor f => Int -> LensLike' f (IntMap.IntMap v) (Maybe v)
intAt :: Int -> LensLike' f (IntMap v) (Maybe v)
intAt = ((Maybe v -> f (Maybe v)) -> Int -> IntMap v -> f (IntMap v))
-> Int -> LensLike' f (IntMap v) (Maybe v)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Maybe v -> f (Maybe v)) -> Int -> IntMap v -> f (IntMap v)
forall (f :: * -> *) a.
Functor f =>
(Maybe a -> f (Maybe a)) -> Int -> IntMap a -> f (IntMap a)
IntMap.alterF
at' :: (Ord k, Functor f) => k -> LensLike' f (Map.Map k v) (Maybe v)
at' :: k -> LensLike' f (Map k v) (Maybe v)
at' = ((Maybe v -> f (Maybe v)) -> k -> Map k v -> f (Map k v))
-> k -> LensLike' f (Map k v) (Maybe v)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Maybe v -> f (Maybe v)) -> k -> Map k v -> f (Map k v)
forall (f :: * -> *) k a.
(Functor f, Ord k) =>
(Maybe a -> f (Maybe a)) -> k -> Map k a -> f (Map k a)
Map'.alterF
intAt' :: Functor f => Int -> LensLike' f (IntMap.IntMap v) (Maybe v)
intAt' :: Int -> LensLike' f (IntMap v) (Maybe v)
intAt' = ((Maybe v -> f (Maybe v)) -> Int -> IntMap v -> f (IntMap v))
-> Int -> LensLike' f (IntMap v) (Maybe v)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Maybe v -> f (Maybe v)) -> Int -> IntMap v -> f (IntMap v)
forall (f :: * -> *) a.
Functor f =>
(Maybe a -> f (Maybe a)) -> Int -> IntMap a -> f (IntMap a)
IntMap'.alterF
contains :: (Ord k, Functor f) => k -> LensLike' f (Set.Set k) Bool
contains :: k -> LensLike' f (Set k) Bool
contains k
k = (Set k -> Bool)
-> (Set k -> Bool -> Set k) -> LensLike' f (Set k) Bool
forall (f :: * -> *) s a b t.
Functor f =>
(s -> a) -> (s -> b -> t) -> LensLike f s t a b
lens (k -> Set k -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.member k
k) (\Set k
m Bool
nv -> if Bool
nv then k -> Set k -> Set k
forall a. Ord a => a -> Set a -> Set a
Set.insert k
k Set k
m else k -> Set k -> Set k
forall a. Ord a => a -> Set a -> Set a
Set.delete k
k Set k
m)
intContains :: Functor f => Int -> LensLike' f IntSet.IntSet Bool
intContains :: Int -> LensLike' f IntSet Bool
intContains Int
k = (IntSet -> Bool)
-> (IntSet -> Bool -> IntSet) -> LensLike' f IntSet Bool
forall (f :: * -> *) s a b t.
Functor f =>
(s -> a) -> (s -> b -> t) -> LensLike f s t a b
lens (Int -> IntSet -> Bool
IntSet.member Int
k) (\IntSet
m Bool
nv -> if Bool
nv then Int -> IntSet -> IntSet
IntSet.insert Int
k IntSet
m else Int -> IntSet -> IntSet
IntSet.delete Int
k IntSet
m)
cod :: Functor g => GrateLike g (r -> a) (r -> b) a b
cod :: GrateLike g (r -> a) (r -> b) a b
cod g a -> b
f g (r -> a)
h r
r = g a -> b
f (g a -> b) -> g a -> b
forall a b. (a -> b) -> a -> b
$ ((r -> a) -> r -> a
forall a b. (a -> b) -> a -> b
$ r
r) ((r -> a) -> a) -> g (r -> a) -> g a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> g (r -> a)
h
left :: (Applicative f, Traversable g) => AdapterLike f g (Either a r) (Either b r) a b
left :: AdapterLike f g (Either a r) (Either b r) a b
left g a -> f b
f = (r -> f (Either b r))
-> (g a -> f (Either b r)) -> Either r (g a) -> f (Either b r)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Either b r -> f (Either b r)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either b r -> f (Either b r))
-> (r -> Either b r) -> r -> f (Either b r)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> Either b r
forall a b. b -> Either a b
Right) ((b -> Either b r) -> f b -> f (Either b r)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> Either b r
forall a b. a -> Either a b
Left (f b -> f (Either b r)) -> (g a -> f b) -> g a -> f (Either b r)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g a -> f b
f) (Either r (g a) -> f (Either b r))
-> (g (Either a r) -> Either r (g a))
-> g (Either a r)
-> f (Either b r)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Either a r -> Either r a) -> g (Either a r) -> Either r (g a)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Either a r -> Either r a
forall b a. Either b a -> Either a b
switch
where
switch :: Either b a -> Either a b
switch = (b -> Either a b) -> (a -> Either a b) -> Either b a -> Either a b
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either b -> Either a b
forall a b. b -> Either a b
Right a -> Either a b
forall a b. a -> Either a b
Left
left_ :: Applicative f => LensLike f (Either a r) (Either b r) a b
left_ :: LensLike f (Either a r) (Either b r) a b
left_ = AResetter (Either a r) (f (Either b r)) a (f b)
-> LensLike f (Either a r) (Either b r) a b
forall s t a b. AResetter s t a b -> (a -> b) -> s -> t
under AResetter (Either a r) (f (Either b r)) a (f b)
forall (f :: * -> *) (g :: * -> *) a r b.
(Applicative f, Traversable g) =>
AdapterLike f g (Either a r) (Either b r) a b
left
right :: (Applicative f, Traversable g) => AdapterLike f g (Either r a) (Either r b) a b
right :: AdapterLike f g (Either r a) (Either r b) a b
right g a -> f b
f = (r -> f (Either r b))
-> (g a -> f (Either r b)) -> Either r (g a) -> f (Either r b)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Either r b -> f (Either r b)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either r b -> f (Either r b))
-> (r -> Either r b) -> r -> f (Either r b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> Either r b
forall a b. a -> Either a b
Left) ((b -> Either r b) -> f b -> f (Either r b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> Either r b
forall a b. b -> Either a b
Right (f b -> f (Either r b)) -> (g a -> f b) -> g a -> f (Either r b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g a -> f b
f) (Either r (g a) -> f (Either r b))
-> (g (Either r a) -> Either r (g a))
-> g (Either r a)
-> f (Either r b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g (Either r a) -> Either r (g a)
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA
right_ :: Applicative f => LensLike f (Either r a) (Either r b) a b
right_ :: LensLike f (Either r a) (Either r b) a b
right_ = AResetter (Either r a) (f (Either r b)) a (f b)
-> LensLike f (Either r a) (Either r b) a b
forall s t a b. AResetter s t a b -> (a -> b) -> s -> t
under AResetter (Either r a) (f (Either r b)) a (f b)
forall (f :: * -> *) (g :: * -> *) r a b.
(Applicative f, Traversable g) =>
AdapterLike f g (Either r a) (Either r b) a b
right
just :: (Applicative f, Traversable g) => AdapterLike f g (Maybe a) (Maybe b) a b
just :: AdapterLike f g (Maybe a) (Maybe b) a b
just g a -> f b
f = f (Maybe b) -> (g a -> f (Maybe b)) -> Maybe (g a) -> f (Maybe b)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Maybe b -> f (Maybe b)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe b
forall a. Maybe a
Nothing) ((b -> Maybe b) -> f b -> f (Maybe b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> Maybe b
forall a. a -> Maybe a
Just (f b -> f (Maybe b)) -> (g a -> f b) -> g a -> f (Maybe b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g a -> f b
f) (Maybe (g a) -> f (Maybe b))
-> (g (Maybe a) -> Maybe (g a)) -> g (Maybe a) -> f (Maybe b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g (Maybe a) -> Maybe (g a)
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA
just_ :: Applicative f => LensLike f (Maybe a) (Maybe b) a b
just_ :: LensLike f (Maybe a) (Maybe b) a b
just_ = AResetter (Maybe a) (f (Maybe b)) a (f b)
-> LensLike f (Maybe a) (Maybe b) a b
forall s t a b. AResetter s t a b -> (a -> b) -> s -> t
under AResetter (Maybe a) (f (Maybe b)) a (f b)
forall (f :: * -> *) (g :: * -> *) a b.
(Applicative f, Traversable g) =>
AdapterLike f g (Maybe a) (Maybe b) a b
just
nothing :: (Applicative f, Traversable g) => AdapterLike' f g (Maybe a) ()
nothing :: AdapterLike' f g (Maybe a) ()
nothing = (Maybe a -> Either (Maybe a) ())
-> (() -> Maybe a) -> AdapterLike' f g (Maybe a) ()
forall (f :: * -> *) (g :: * -> *) s t a b.
(Applicative f, Traversable g) =>
(s -> Either t a) -> (b -> t) -> AdapterLike f g s t a b
prism (Either (Maybe a) ()
-> (a -> Either (Maybe a) ()) -> Maybe a -> Either (Maybe a) ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (() -> Either (Maybe a) ()
forall a b. b -> Either a b
Right ()) (Maybe a -> Either (Maybe a) ()
forall a b. a -> Either a b
Left (Maybe a -> Either (Maybe a) ())
-> (a -> Maybe a) -> a -> Either (Maybe a) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Maybe a
forall a. a -> Maybe a
Just)) (Maybe a -> () -> Maybe a
forall a b. a -> b -> a
const Maybe a
forall a. Maybe a
Nothing)
nothing_ :: Applicative f => LensLike' f (Maybe a) ()
nothing_ :: LensLike' f (Maybe a) ()
nothing_ = AResetter (Maybe a) (f (Maybe a)) () (f ())
-> LensLike' f (Maybe a) ()
forall s t a b. AResetter s t a b -> (a -> b) -> s -> t
under AResetter (Maybe a) (f (Maybe a)) () (f ())
forall (f :: * -> *) (g :: * -> *) a.
(Applicative f, Traversable g) =>
AdapterLike' f g (Maybe a) ()
nothing
both :: (Applicative f, Functor g) => AdapterLike f g (a,a) (b,b) a b
both :: AdapterLike f g (a, a) (b, b) a b
both = AdapterLike f g a b a b
-> AdapterLike f g a b a b -> AdapterLike f g (a, a) (b, b) a b
forall (f :: * -> *) (g :: * -> *) s0 t0 a b s1 t1.
(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 AdapterLike f g a b a b
forall a. a -> a
id AdapterLike f g a b a b
forall a. a -> a
id
both' :: Functor g => GrateLike g (a,a) (b,b) a b
both' :: GrateLike g (a, a) (b, b) a b
both' = GrateLike g a b a b
-> GrateLike g a b a b -> GrateLike g (a, a) (b, b) a b
forall (g :: * -> *) s0 t0 a b s1 t1.
Functor g =>
GrateLike g s0 t0 a b
-> GrateLike g s1 t1 a b -> GrateLike g (s0, s1) (t0, t1) a b
beside' GrateLike g a b a b
forall a. a -> a
id GrateLike g a b a b
forall a. a -> a
id
both_ :: Applicative f => LensLike f (a,a) (b,b) a b
both_ :: LensLike f (a, a) (b, b) a b
both_ = LensLike f a b a b
-> LensLike f a b a b -> LensLike f (a, a) (b, b) a b
forall (f :: * -> *) s0 t0 a b s1 t1.
Applicative f =>
LensLike f s0 t0 a b
-> LensLike f s1 t1 a b -> LensLike f (s0, s1) (t0, t1) a b
beside_ LensLike f a b a b
forall a. a -> a
id LensLike f a b a b
forall a. a -> a
id
lend :: (FiniteBits b, Applicative f, Functor g) => AdapterLike' f g b Bool
lend :: AdapterLike' f g b Bool
lend g Bool -> f Bool
f g b
s = (f b -> f b -> f b) -> f b -> [f b] -> f b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ((b -> b -> b) -> f b -> f b -> f b
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 b -> b -> b
forall a. Bits a => a -> a -> a
(.|.)) (b -> f b
forall (f :: * -> *) a. Applicative f => a -> f a
pure b
forall a. Bits a => a
zeroBits) [Int -> Bool -> b
forall p. Bits p => Int -> Bool -> p
mask Int
i (Bool -> b) -> f Bool -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> g Bool -> f Bool
f ((b -> Int -> Bool) -> Int -> b -> Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip b -> Int -> Bool
forall a. Bits a => a -> Int -> Bool
testBit Int
i (b -> Bool) -> g b -> g Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> g b
s) | Int
i <- [Int
0..b -> Int
forall b. FiniteBits b => b -> Int
finiteBitSize b
bInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1]]
where
mask :: Int -> Bool -> p
mask Int
i Bool
True = Int -> p
forall a. Bits a => Int -> a
bit Int
i
mask Int
_ Bool
False = p
forall a. Bits a => a
zeroBits
b :: b
b = b
b b -> g b -> b
forall a (proxy :: * -> *). a -> proxy a -> a
`asProxyTypeOf` g b
s
lend' :: (FiniteBits b, Functor g) => GrateLike' g b Bool
lend' :: GrateLike' g b Bool
lend' = ASetter (g b) b (g Bool) Bool -> GrateLike' g b Bool
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter (g b) b (g Bool) Bool
forall b (f :: * -> *) (g :: * -> *).
(FiniteBits b, Applicative f, Functor g) =>
AdapterLike' f g b Bool
lend
lend_ :: (FiniteBits b, Applicative f) => LensLike' f b Bool
lend_ :: LensLike' f b Bool
lend_ = AResetter b (f b) Bool (f Bool) -> LensLike' f b Bool
forall s t a b. AResetter s t a b -> (a -> b) -> s -> t
under AResetter b (f b) Bool (f Bool)
forall b (f :: * -> *) (g :: * -> *).
(FiniteBits b, Applicative f, Functor g) =>
AdapterLike' f g b Bool
lend
bend :: (FiniteBits b, Applicative f, Functor g) => AdapterLike' f g b Bool
bend :: AdapterLike' f g b Bool
bend = LensLike (Backwards f) (g b) b (g Bool) Bool
-> AdapterLike' f g b Bool
forall (f :: * -> *) s t a b.
LensLike (Backwards f) s t a b -> LensLike f s t a b
backwards LensLike (Backwards f) (g b) b (g Bool) Bool
forall b (f :: * -> *) (g :: * -> *).
(FiniteBits b, Applicative f, Functor g) =>
AdapterLike' f g b Bool
lend
bend' :: (FiniteBits b, Functor g) => GrateLike' g b Bool
bend' :: GrateLike' g b Bool
bend' = ASetter (g b) b (g Bool) Bool -> GrateLike' g b Bool
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter (g b) b (g Bool) Bool
forall b (f :: * -> *) (g :: * -> *).
(FiniteBits b, Applicative f, Functor g) =>
AdapterLike' f g b Bool
bend
bend_ :: (FiniteBits b, Applicative f) => LensLike' f b Bool
bend_ :: LensLike' f b Bool
bend_ = AResetter b (f b) Bool (f Bool) -> LensLike' f b Bool
forall s t a b. AResetter s t a b -> (a -> b) -> s -> t
under AResetter b (f b) Bool (f Bool)
forall b (f :: * -> *) (g :: * -> *).
(FiniteBits b, Applicative f, Functor g) =>
AdapterLike' f g b Bool
bend
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 :: AdapterLike f g s0 t0 a b
-> AdapterLike f g s1 t1 a b
-> AdapterLike f g (s0, s1) (t0, t1) a b
beside AdapterLike f g s0 t0 a b
la AdapterLike f g s1 t1 a b
lb g a -> f b
f g (s0, s1)
s = (,) (t0 -> t1 -> (t0, t1)) -> f t0 -> f (t1 -> (t0, t1))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AdapterLike f g s0 t0 a b
la g a -> f b
f ((s0, s1) -> s0
forall a b. (a, b) -> a
fst ((s0, s1) -> s0) -> g (s0, s1) -> g s0
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> g (s0, s1)
s) f (t1 -> (t0, t1)) -> f t1 -> f (t0, t1)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> AdapterLike f g s1 t1 a b
lb g a -> f b
f ((s0, s1) -> s1
forall a b. (a, b) -> b
snd ((s0, s1) -> s1) -> g (s0, s1) -> g s1
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> g (s0, s1)
s)
beside' :: Functor g => GrateLike g s0 t0 a b -> GrateLike g s1 t1 a b -> GrateLike g (s0, s1) (t0, t1) a b
beside' :: GrateLike g s0 t0 a b
-> GrateLike g s1 t1 a b -> GrateLike g (s0, s1) (t0, t1) a b
beside' GrateLike g s0 t0 a b
la GrateLike g s1 t1 a b
lb = ASetter (g (s0, s1)) (t0, t1) (g a) b
-> GrateLike g (s0, s1) (t0, t1) a b
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over (ASetter (g (s0, s1)) (t0, t1) (g a) b
-> GrateLike g (s0, s1) (t0, t1) a b)
-> ASetter (g (s0, s1)) (t0, t1) (g a) b
-> GrateLike g (s0, s1) (t0, t1) a b
forall a b. (a -> b) -> a -> b
$ AdapterLike Identity g s0 t0 a b
-> AdapterLike Identity g s1 t1 a b
-> ASetter (g (s0, s1)) (t0, t1) (g a) b
forall (f :: * -> *) (g :: * -> *) s0 t0 a b s1 t1.
(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 (GrateLike g s0 t0 a b -> AdapterLike Identity g s0 t0 a b
forall (f :: * -> *) a b s t.
Identical f =>
((a -> b) -> s -> t) -> LensLike f s t a b
setting GrateLike g s0 t0 a b
la) (GrateLike g s1 t1 a b -> AdapterLike Identity g s1 t1 a b
forall (f :: * -> *) a b s t.
Identical f =>
((a -> b) -> s -> t) -> LensLike f s t a b
setting GrateLike g s1 t1 a b
lb)
beside_ :: Applicative f => LensLike f s0 t0 a b -> LensLike f s1 t1 a b -> LensLike f (s0, s1) (t0, t1) a b
beside_ :: LensLike f s0 t0 a b
-> LensLike f s1 t1 a b -> LensLike f (s0, s1) (t0, t1) a b
beside_ LensLike f s0 t0 a b
la LensLike f s1 t1 a b
lb = AResetter (s0, s1) (f (t0, t1)) a (f b)
-> LensLike f (s0, s1) (t0, t1) a b
forall s t a b. AResetter s t a b -> (a -> b) -> s -> t
under (AResetter (s0, s1) (f (t0, t1)) a (f b)
-> LensLike f (s0, s1) (t0, t1) a b)
-> AResetter (s0, s1) (f (t0, t1)) a (f b)
-> LensLike f (s0, s1) (t0, t1) a b
forall a b. (a -> b) -> a -> b
$ AdapterLike f Identity s0 t0 a b
-> AdapterLike f Identity s1 t1 a b
-> AResetter (s0, s1) (f (t0, t1)) a (f b)
forall (f :: * -> *) (g :: * -> *) s0 t0 a b s1 t1.
(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 (LensLike f s0 t0 a b -> AdapterLike f Identity s0 t0 a b
forall (g :: * -> *) a b s t.
Identical g =>
((a -> b) -> s -> t) -> GrateLike g s t a b
resetting LensLike f s0 t0 a b
la) (LensLike f s1 t1 a b -> AdapterLike f Identity s1 t1 a b
forall (g :: * -> *) a b s t.
Identical g =>
((a -> b) -> s -> t) -> GrateLike g s t a b
resetting LensLike f s1 t1 a b
lb)
ignored :: Applicative f => null -> s -> f s
ignored :: null -> s -> f s
ignored null
_ = s -> f s
forall (f :: * -> *) a. Applicative f => a -> f a
pure
mapped :: (Identical f, Functor h) => LensLike f (h a) (h b) a b
mapped :: LensLike f (h a) (h b) a b
mapped = ((a -> b) -> h a -> h b) -> LensLike f (h a) (h b) a b
forall (f :: * -> *) a b s t.
Identical f =>
((a -> b) -> s -> t) -> LensLike f s t a b
setting (a -> b) -> h a -> h b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
backwards :: LensLike (Backwards f) s t a b -> LensLike f s t a b
backwards :: LensLike (Backwards f) s t a b -> LensLike f s t a b
backwards LensLike (Backwards f) s t a b
l a -> f b
f = Backwards f t -> f t
forall k (f :: k -> *) (a :: k). Backwards f a -> f a
forwards (Backwards f t -> f t) -> (s -> Backwards f t) -> s -> f t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike (Backwards f) s t a b
l (f b -> Backwards f b
forall k (f :: k -> *) (a :: k). f a -> Backwards f a
Backwards (f b -> Backwards f b) -> (a -> f b) -> a -> Backwards f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> f b
f)
newtype AlongsideLeft f b a = AlongsideLeft (f (a, b))
instance Functor f => Functor (AlongsideLeft f a) where
fmap :: (a -> b) -> AlongsideLeft f a a -> AlongsideLeft f a b
fmap a -> b
f (AlongsideLeft f (a, a)
x) = f (b, a) -> AlongsideLeft f a b
forall (f :: * -> *) b a. f (a, b) -> AlongsideLeft f b a
AlongsideLeft (((a, a) -> (b, a)) -> f (a, a) -> f (b, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> (a, a) -> (b, a)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first a -> b
f) f (a, a)
x)
instance Phantom f => Phantom (AlongsideLeft f a) where
coerce :: AlongsideLeft f a a -> AlongsideLeft f a b
coerce (AlongsideLeft f (a, a)
x) = f (b, a) -> AlongsideLeft f a b
forall (f :: * -> *) b a. f (a, b) -> AlongsideLeft f b a
AlongsideLeft (f (a, a) -> f (b, a)
forall (f :: * -> *) a b. Phantom f => f a -> f b
coerce f (a, a)
x)
newtype AlongsideRight f a b = AlongsideRight (f (a, b))
instance Functor f => Functor (AlongsideRight f a) where
fmap :: (a -> b) -> AlongsideRight f a a -> AlongsideRight f a b
fmap a -> b
f (AlongsideRight f (a, a)
x) = f (a, b) -> AlongsideRight f a b
forall (f :: * -> *) a b. f (a, b) -> AlongsideRight f a b
AlongsideRight (((a, a) -> (a, b)) -> f (a, a) -> f (a, b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> (a, a) -> (a, b)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second a -> b
f) f (a, a)
x)
instance Phantom f => Phantom (AlongsideRight f a) where
coerce :: AlongsideRight f a a -> AlongsideRight f a b
coerce (AlongsideRight f (a, a)
x) = f (a, b) -> AlongsideRight f a b
forall (f :: * -> *) a b. f (a, b) -> AlongsideRight f a b
AlongsideRight (f (a, a) -> f (a, b)
forall (f :: * -> *) a b. Phantom f => f a -> f b
coerce f (a, a)
x)
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 :: 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 LensLike (AlongsideLeft f b1) s0 t0 a0 b0
l0 LensLike (AlongsideRight f t0) s1 t1 a1 b1
l1 (a0, a1) -> f (b0, b1)
f (s0
s0, s1
s1) = f (t0, t1)
ft0t1
where
AlongsideRight f (t0, t1)
ft0t1 = LensLike (AlongsideRight f t0) s1 t1 a1 b1
l1 a1 -> AlongsideRight f t0 b1
f1 s1
s1
f1 :: a1 -> AlongsideRight f t0 b1
f1 a1
a1 = f (t0, b1) -> AlongsideRight f t0 b1
forall (f :: * -> *) a b. f (a, b) -> AlongsideRight f a b
AlongsideRight f (t0, b1)
ft0a1
where
AlongsideLeft f (t0, b1)
ft0a1 = LensLike (AlongsideLeft f b1) s0 t0 a0 b0
l0 a0 -> AlongsideLeft f b1 b0
f0 s0
s0
f0 :: a0 -> AlongsideLeft f b1 b0
f0 a0
a0 = f (b0, b1) -> AlongsideLeft f b1 b0
forall (f :: * -> *) b a. f (a, b) -> AlongsideLeft f b a
AlongsideLeft ((a0, a1) -> f (b0, b1)
f (a0
a0, a1
a1))
newtype FromF i j g x = FromF ((g x -> j) -> i)
instance Functor g => Functor (FromF i j g) where
fmap :: (a -> b) -> FromF i j g a -> FromF i j g b
fmap a -> b
f (FromF (g a -> j) -> i
h) = ((g b -> j) -> i) -> FromF i j g b
forall i j (g :: * -> *) x. ((g x -> j) -> i) -> FromF i j g x
FromF (((g b -> j) -> i) -> FromF i j g b)
-> ((g b -> j) -> i) -> FromF i j g b
forall a b. (a -> b) -> a -> b
$ \g b -> j
k -> (g a -> j) -> i
h (g b -> j
k (g b -> j) -> (g a -> g b) -> g a -> j
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f)
instance Phantom g => Phantom (FromF i j g) where
coerce :: FromF i j g a -> FromF i j g b
coerce (FromF (g a -> j) -> i
h) = ((g b -> j) -> i) -> FromF i j g b
forall i j (g :: * -> *) x. ((g x -> j) -> i) -> FromF i j g x
FromF (((g b -> j) -> i) -> FromF i j g b)
-> ((g b -> j) -> i) -> FromF i j g b
forall a b. (a -> b) -> a -> b
$ \g b -> j
k -> (g a -> j) -> i
h (g b -> j
k (g b -> j) -> (g a -> g b) -> g a -> j
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g a -> g b
forall (f :: * -> *) a b. Phantom f => f a -> f b
coerce)
newtype FromG e f x = FromG (e -> f x)
instance Functor f => Functor (FromG e f) where
fmap :: (a -> b) -> FromG e f a -> FromG e f b
fmap a -> b
f (FromG e -> f a
h) = (e -> f b) -> FromG e f b
forall e (f :: * -> *) x. (e -> f x) -> FromG e f x
FromG ((e -> f b) -> FromG e f b) -> (e -> f b) -> FromG e f b
forall a b. (a -> b) -> a -> b
$ (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f (f a -> f b) -> (e -> f a) -> e -> f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> f a
h
instance Phantom g => Phantom (FromG e g) where
coerce :: FromG e g a -> FromG e g b
coerce (FromG e -> g a
h) = (e -> g b) -> FromG e g b
forall e (f :: * -> *) x. (e -> f x) -> FromG e f x
FromG ((e -> g b) -> FromG e g b) -> (e -> g b) -> FromG e g b
forall a b. (a -> b) -> a -> b
$ g a -> g b
forall (f :: * -> *) a b. Phantom f => f a -> f b
coerce (g a -> g b) -> (e -> g a) -> e -> g b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> g a
h
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 :: 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 AdapterLike (FromF (g s -> f t) (f b) g) (FromG (f b) f) b a t s
l = AdapterLike f g s t a b
l'
where
FromF AdapterLike f g s t a b
l' = AdapterLike (FromF (g s -> f t) (f b) g) (FromG (f b) f) b a t s
l (\(FromG f b -> f t
h1) -> ((g s -> f b) -> g s -> f t) -> FromF (g s -> f t) (f b) g s
forall i j (g :: * -> *) x. ((g x -> j) -> i) -> FromF i j g x
FromF (((g s -> f b) -> g s -> f t) -> FromF (g s -> f t) (f b) g s)
-> ((g s -> f b) -> g s -> f t) -> FromF (g s -> f t) (f b) g s
forall a b. (a -> b) -> a -> b
$ (f b -> f t) -> (g s -> f b) -> g s -> f t
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) f b -> f t
h1) ((f b -> f b) -> FromG (f b) f b
forall e (f :: * -> *) x. (e -> f x) -> FromG e f x
FromG f b -> f b
forall a. a -> a
id)
{-# DEPRECATED lft "Renamed as 'left'." #-}
lft :: (Applicative f, Traversable g) => AdapterLike f g (Either a r) (Either b r) a b
lft :: AdapterLike f g (Either a r) (Either b r) a b
lft = AdapterLike f g (Either a r) (Either b r) a b
forall (f :: * -> *) (g :: * -> *) a r b.
(Applicative f, Traversable g) =>
AdapterLike f g (Either a r) (Either b r) a b
left
{-# DEPRECATED lft_ "Renamed as 'left_'." #-}
lft_ :: Applicative f => LensLike f (Either a r) (Either b r) a b
lft_ :: LensLike f (Either a r) (Either b r) a b
lft_ = LensLike f (Either a r) (Either b r) a b
forall (f :: * -> *) a r b.
Applicative f =>
LensLike f (Either a r) (Either b r) a b
left_
{-# DEPRECATED rgt "Renamed as 'right'." #-}
rgt :: (Applicative f, Traversable g) => AdapterLike f g (Either r a) (Either r b) a b
rgt :: AdapterLike f g (Either r a) (Either r b) a b
rgt = AdapterLike f g (Either r a) (Either r b) a b
forall (f :: * -> *) (g :: * -> *) r a b.
(Applicative f, Traversable g) =>
AdapterLike f g (Either r a) (Either r b) a b
right
{-# DEPRECATED rgt_ "Renamed as 'right_'." #-}
rgt_ :: Applicative f => LensLike f (Either r a) (Either r b) a b
rgt_ :: LensLike f (Either r a) (Either r b) a b
rgt_ = LensLike f (Either r a) (Either r b) a b
forall (f :: * -> *) r a b.
Applicative f =>
LensLike f (Either r a) (Either r b) a b
right_
{-# DEPRECATED some "Renamed as 'just'." #-}
some :: (Applicative f, Traversable g) => AdapterLike f g (Maybe a) (Maybe b) a b
some :: AdapterLike f g (Maybe a) (Maybe b) a b
some = AdapterLike f g (Maybe a) (Maybe b) a b
forall (f :: * -> *) (g :: * -> *) a b.
(Applicative f, Traversable g) =>
AdapterLike f g (Maybe a) (Maybe b) a b
just
{-# DEPRECATED some_ "Renamed as 'just_'." #-}
some_ :: Applicative f => LensLike f (Maybe a) (Maybe b) a b
some_ :: LensLike f (Maybe a) (Maybe b) a b
some_ = LensLike f (Maybe a) (Maybe b) a b
forall (f :: * -> *) a b.
Applicative f =>
LensLike f (Maybe a) (Maybe b) a b
just_
{-# DEPRECATED none "Renamed as 'nothing'." #-}
none :: (Applicative f, Traversable g) => AdapterLike' f g (Maybe a) ()
none :: AdapterLike' f g (Maybe a) ()
none = AdapterLike' f g (Maybe a) ()
forall (f :: * -> *) (g :: * -> *) a.
(Applicative f, Traversable g) =>
AdapterLike' f g (Maybe a) ()
nothing
{-# DEPRECATED none_ "Renamed as 'nothing_'." #-}
none_ :: Applicative f => LensLike' f (Maybe a) ()
none_ :: LensLike' f (Maybe a) ()
none_ = LensLike' f (Maybe a) ()
forall (f :: * -> *) a. Applicative f => LensLike' f (Maybe a) ()
nothing_