module Lens.Family.Clone
( cloneAdapter, cloneLens, cloneGrate, cloneTraversal, cloneSetter, cloneResetter, cloneGetter, cloneFold
, AnAdapter, AnAdapter'
, ALens, ALens'
, ATraversal, ATraversal'
, AGetter, AGetter'
, AFold, AFold'
, PStore, PKleeneStore
, LensLike, LensLike', GrateLike, GrateLike', FoldLike, FoldLike', AGrate, ASetter, AResetter
, Phantom, Identical
) where
import Lens.Family.Unchecked
import Lens.Family
data PStore i j a = PStore (j -> a) i
instance Functor (PStore i j) where
fmap :: forall a b. (a -> b) -> PStore i j a -> PStore i j b
fmap a -> b
f (PStore j -> a
g i
i) = forall i j a. (j -> a) -> i -> PStore i j a
PStore (a -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. j -> a
g) i
i
type AnAdapter s t a b = AdapterLike (PStore (s -> a) b) ((->) s) s t a b
type AnAdapter' s a = AdapterLike' (PStore (s -> a) a) ((->) s) s a
cloneAdapter :: (Functor f, Functor g) => AnAdapter s t a b -> AdapterLike f g s t a b
cloneAdapter :: forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnAdapter s t a b -> AdapterLike f g s t a b
cloneAdapter AnAdapter s t a b
univ = forall (f :: * -> *) (g :: * -> *) s a b t.
(Functor f, Functor g) =>
(s -> a) -> (b -> t) -> AdapterLike f g s t a b
adapter s -> a
yin b -> t
yang
where
PStore b -> t
yang s -> a
yin = AnAdapter s t a b
univ (forall i j a. (j -> a) -> i -> PStore i j a
PStore forall a. a -> a
id) forall a. a -> a
id
type ALens s t a b = LensLike (PStore a b) s t a b
type ALens' s a = LensLike' (PStore a a) s a
cloneLens :: Functor f => ALens s t a b -> LensLike f s t a b
cloneLens :: forall (f :: * -> *) s t a b.
Functor f =>
ALens s t a b -> LensLike f s t a b
cloneLens ALens s t a b
univ a -> f b
f = forall (f :: * -> *) a b t.
Functor f =>
(a -> f b) -> PStore a b t -> f t
experiment a -> f b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. ALens s t a b
univ (forall i j a. (j -> a) -> i -> PStore i j a
PStore forall a. a -> a
id)
experiment :: Functor f => (a -> f b) -> PStore a b t -> f t
experiment :: forall (f :: * -> *) a b t.
Functor f =>
(a -> f b) -> PStore a b t -> f t
experiment a -> f b
f (PStore b -> t
g a
a) = b -> t
g forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a
data PKleeneStore i j a = Unit a
| Battery (PKleeneStore i j (j -> a)) i
instance Functor (PKleeneStore i j) where
fmap :: forall a b. (a -> b) -> PKleeneStore i j a -> PKleeneStore i j b
fmap a -> b
f (Unit a
a) = forall i j a. a -> PKleeneStore i j a
Unit (a -> b
f a
a)
fmap a -> b
f (Battery PKleeneStore i j (j -> a)
g i
i) = forall i j a. PKleeneStore i j (j -> a) -> i -> PKleeneStore i j a
Battery (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
.) PKleeneStore i j (j -> a)
g) i
i
instance Applicative (PKleeneStore i j) where
pure :: forall a. a -> PKleeneStore i j a
pure = forall i j a. a -> PKleeneStore i j a
Unit
Unit a -> b
f <*> :: forall a b.
PKleeneStore i j (a -> b)
-> PKleeneStore i j a -> PKleeneStore i j b
<*> PKleeneStore i j a
a = a -> b
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PKleeneStore i j a
a
Battery PKleeneStore i j (j -> a -> b)
f i
b <*> PKleeneStore i j a
a = forall i j a. PKleeneStore i j (j -> a) -> i -> PKleeneStore i j a
Battery (forall a b c. (a -> b -> c) -> b -> a -> c
flip forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PKleeneStore i j (j -> a -> b)
f forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> PKleeneStore i j a
a) i
b
type ATraversal s t a b = LensLike (PKleeneStore a b) s t a b
type ATraversal' s a = LensLike' (PKleeneStore a a) s a
cloneTraversal :: Applicative f => ATraversal s t a b -> LensLike f s t a b
cloneTraversal :: forall (f :: * -> *) s t a b.
Applicative f =>
ATraversal s t a b -> LensLike f s t a b
cloneTraversal ATraversal s t a b
univ a -> f b
f = forall (f :: * -> *) a b t.
Applicative f =>
(a -> f b) -> PKleeneStore a b t -> f t
research a -> f b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. ATraversal s t a b
univ (forall i j a. PKleeneStore i j (j -> a) -> i -> PKleeneStore i j a
Battery (forall i j a. a -> PKleeneStore i j a
Unit forall a. a -> a
id))
research :: Applicative f => (a -> f b) -> PKleeneStore a b t -> f t
research :: forall (f :: * -> *) a b t.
Applicative f =>
(a -> f b) -> PKleeneStore a b t -> f t
research a -> f b
_ (Unit t
a) = forall (f :: * -> *) a. Applicative f => a -> f a
pure t
a
research a -> f b
f (Battery PKleeneStore a b (b -> t)
g a
b) = forall (f :: * -> *) a b t.
Applicative f =>
(a -> f b) -> PKleeneStore a b t -> f t
research a -> f b
f PKleeneStore a b (b -> t)
g forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
f a
b
cloneSetter :: Identical f => ASetter s t a b -> LensLike f s t a b
cloneSetter :: forall (f :: * -> *) s t a b.
Identical f =>
ASetter s t a b -> LensLike f s t a b
cloneSetter = forall (f :: * -> *) a b s t.
Identical f =>
((a -> b) -> s -> t) -> LensLike f s t a b
setting forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over
type AFold s t a b = FoldLike [a] s t a b
type AFold' s a = FoldLike' [a] s a
cloneFold :: (Phantom f, Applicative f) => AFold s t a b -> LensLike f s t a b
cloneFold :: forall (f :: * -> *) s t a b.
(Phantom f, Applicative f) =>
AFold s t a b -> LensLike f s t a b
cloneFold AFold s t a b
univ = forall (g :: * -> *) (f :: * -> *) s a t b.
(Foldable g, Phantom f, Applicative f) =>
(s -> g a) -> LensLike f s t a b
folding (forall a s t b. FoldLike [a] s t a b -> s -> [a]
toListOf AFold s t a b
univ)
cloneResetter :: Identical f => AResetter s t a b -> GrateLike f s t a b
cloneResetter :: forall (f :: * -> *) s t a b.
Identical f =>
AResetter s t a b -> GrateLike f s t a b
cloneResetter = forall (g :: * -> *) a b s t.
Identical g =>
((a -> b) -> s -> t) -> GrateLike g s t a b
resetting forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s t a b. AResetter s t a b -> (a -> b) -> s -> t
under
type AGetter s t a b = FoldLike a s t a b
type AGetter' s a = FoldLike' a s a
cloneGetter :: Phantom f => AGetter s t a b -> LensLike f s t a b
cloneGetter :: forall (f :: * -> *) s t a b.
Phantom f =>
AGetter s t a b -> LensLike f s t a b
cloneGetter AGetter s t a b
univ = forall (f :: * -> *) s a t b.
Phantom f =>
(s -> a) -> LensLike f s t a b
to (forall a s t b. FoldLike a s t a b -> s -> a
view AGetter s t a b
univ)
cloneGrate :: Functor g => AGrate s t a b -> GrateLike g s t a b
cloneGrate :: forall (g :: * -> *) s t a b.
Functor g =>
AGrate s t a b -> GrateLike g s t a b
cloneGrate = forall (g :: * -> *) s a b t.
Functor g =>
(((s -> a) -> b) -> t) -> GrateLike g s t a b
grate forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s t a b. AGrate s t a b -> ((s -> a) -> b) -> t
degrating