{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE RankNTypes #-}
{-# OPTIONS_GHC -Wno-warnings-deprecations #-}
module Control.Lens.Unsound
(
lensProduct
, prismSum
, adjoin
) where
import Control.Lens
import Control.Lens.Internal.Prelude
import Prelude ()
lensProduct :: ALens' s a -> ALens' s b -> Lens' s (a, b)
lensProduct :: forall s a b. ALens' s a -> ALens' s b -> Lens' s (a, b)
lensProduct ALens' s a
l1 ALens' s b
l2 (a, b) -> f (a, b)
f s
s =
(a, b) -> f (a, b)
f (s
s forall s t a b. s -> ALens s t a b -> a
^# ALens' s a
l1, s
s forall s t a b. s -> ALens s t a b -> a
^# ALens' s b
l2) forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \(a
a, b
b) -> s
s forall a b. a -> (a -> b) -> b
& ALens' s a
l1 forall s t a b. ALens s t a b -> b -> s -> t
#~ a
a forall a b. a -> (a -> b) -> b
& ALens' s b
l2 forall s t a b. ALens s t a b -> b -> s -> t
#~ b
b
prismSum :: APrism s t a b
-> APrism s t c d
-> Prism s t (Either a c) (Either b d)
prismSum :: forall s t a b c d.
APrism s t a b
-> APrism s t c d -> Prism s t (Either a c) (Either b d)
prismSum APrism s t a b
k APrism s t c d
k' =
forall s t a b r.
APrism s t a b -> ((b -> t) -> (s -> Either t a) -> r) -> r
withPrism APrism s t a b
k forall a b. (a -> b) -> a -> b
$ \b -> t
bt s -> Either t a
seta ->
forall s t a b r.
APrism s t a b -> ((b -> t) -> (s -> Either t a) -> r) -> r
withPrism APrism s t c d
k' forall a b. (a -> b) -> a -> b
$ \d -> t
dt s -> Either t c
setb ->
forall b t s a. (b -> t) -> (s -> Either t a) -> Prism s t a b
prism (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either b -> t
bt d -> t
dt) forall a b. (a -> b) -> a -> b
$ \s
s ->
forall {a} {b}. Either a b -> Either a b -> Either a b
f (forall a b. a -> Either a b
Left forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> s -> Either t a
seta s
s) (forall a b. b -> Either a b
Right forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> s -> Either t c
setb s
s)
where
f :: Either a b -> Either a b -> Either a b
f a :: Either a b
a@(Right b
_) Either a b
_ = Either a b
a
f (Left a
_) Either a b
b = Either a b
b
adjoin :: Traversal' s a -> Traversal' s a -> Traversal' s a
adjoin :: forall s a. Traversal' s a -> Traversal' s a -> Traversal' s a
adjoin Traversal' s a
t1 Traversal' s a
t2 =
forall s a b. ALens' s a -> ALens' s b -> Lens' s (a, b)
lensProduct (forall (f :: * -> *) s t a.
Functor f =>
Traversing (->) f s t a a -> LensLike f s t [a] [a]
partsOf Traversal' s a
t1) (forall (f :: * -> *) s t a.
Functor f =>
Traversing (->) f s t a a -> LensLike f s t [a] [a]
partsOf Traversal' s a
t2) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> * -> *) a b.
Bitraversable r =>
Traversal (r a a) (r b b) a b
both forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s t a b. Each s t a b => Traversal s t a b
each