{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeInType #-}
{-# OPTIONS_HADDOCK not-home #-}
module Optics.Internal.Optic
( Optic(..)
, Optic'
, Optic_
, Optic__
, getOptic
, castOptic
, (%)
, (%%)
, (%&)
, module Optics.Internal.Optic.Subtyping
, module Optics.Internal.Optic.Types
, module Optics.Internal.Optic.TypeLevel
) where
import Data.Function ((&))
import Data.Profunctor.Indexed
import Optics.Internal.Optic.Subtyping
import Optics.Internal.Optic.TypeLevel
import Optics.Internal.Optic.Types
newtype Optic (k :: OpticKind) (is :: IxList) s t a b
= Optic (forall p i. Profunctor p => Optic_ k p i (Curry is i) s t a b)
getOptic
:: Profunctor p
=> Optic k is s t a b
-> Optic_ k p i (Curry is i) s t a b
getOptic :: forall (p :: * -> * -> * -> *) k (is :: IxList) s t a b i.
Profunctor p =>
Optic k is s t a b -> Optic_ k p i (Curry is i) s t a b
getOptic (Optic forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ k p i (Curry is i) s t a b
o) = forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ k p i (Curry is i) s t a b
o
{-# INLINE getOptic #-}
type Optic' k is s a = Optic k is s s a a
type Optic_ k p i j s t a b = Constraints k p => Optic__ p i j s t a b
type Optic__ p i j s t a b = p i a b -> p j s t
castOptic
:: forall destKind srcKind is s t a b
. Is srcKind destKind
=> Optic srcKind is s t a b
-> Optic destKind is s t a b
castOptic :: forall destKind srcKind (is :: IxList) s t a b.
Is srcKind destKind =>
Optic srcKind is s t a b -> Optic destKind is s t a b
castOptic (Optic forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ srcKind p i (Curry is i) s t a b
o) = forall k (is :: IxList) s t a b.
(forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ k p i (Curry is i) s t a b)
-> Optic k is s t a b
Optic (forall (p :: * -> * -> * -> *) i.
Optic_ srcKind p i (Curry is i) s t a b
-> Optic_ destKind p i (Curry is i) s t a b
cast forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ srcKind p i (Curry is i) s t a b
o)
where
cast
:: forall p i
. Optic_ srcKind p i (Curry is i) s t a b
-> Optic_ destKind p i (Curry is i) s t a b
cast :: forall (p :: * -> * -> * -> *) i.
Optic_ srcKind p i (Curry is i) s t a b
-> Optic_ destKind p i (Curry is i) s t a b
cast Optic_ srcKind p i (Curry is i) s t a b
x = forall k l (p :: * -> * -> * -> *) r.
Is k l =>
(Constraints k p => r) -> Constraints l p => r
implies @srcKind @destKind @p Optic_ srcKind p i (Curry is i) s t a b
x
{-# INLINE castOptic #-}
infixl 9 %
(%) :: forall k l m is js ks s t u v a b. (JoinKinds k l m, AppendIndices is js ks)
=> Optic k is s t u v
-> Optic l js u v a b
-> Optic m ks s t a b
Optic forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ k p i (Curry is i) s t u v
k % :: forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% Optic forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ l p i (Curry js i) u v a b
l = forall k (is :: IxList) s t a b.
(forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ k p i (Curry is i) s t a b)
-> Optic k is s t a b
Optic forall (p :: * -> * -> * -> *) i.
(Profunctor p, Constraints m p) =>
Optic__ p i (Curry ks i) s t a b
m
where
km :: forall p i. Profunctor p => Optic_ m p i (Curry is i) s t u v
km :: forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ m p i (Curry is i) s t u v
km = forall k l m (p :: * -> * -> * -> *) r.
JoinKinds k l m =>
((Constraints k p, Constraints l p) => r) -> Constraints m p => r
joinKinds @k @l @m @p forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ k p i (Curry is i) s t u v
k
lm :: forall p i. Profunctor p => Optic_ m p i (Curry js i) u v a b
lm :: forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ m p i (Curry js i) u v a b
lm = forall k l m (p :: * -> * -> * -> *) r.
JoinKinds k l m =>
((Constraints k p, Constraints l p) => r) -> Constraints m p => r
joinKinds @k @l @m @p forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ l p i (Curry js i) u v a b
l
m :: forall p i. (Profunctor p, Constraints m p)
=> Optic__ p i (Curry ks i) s t a b
m :: forall (p :: * -> * -> * -> *) i.
(Profunctor p, Constraints m p) =>
Optic__ p i (Curry ks i) s t a b
m | IxEq i (Curry is (Curry js i)) (Curry ks i)
IxEq <- forall (xs :: IxList) (ys :: IxList) (ks :: IxList) i.
AppendIndices xs ys ks =>
IxEq i (Curry xs (Curry ys i)) (Curry ks i)
appendIndices @is @js @ks @i = forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ m p i (Curry is i) s t u v
km forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ m p i (Curry js i) u v a b
lm
{-# INLINE (%) #-}
infixl 9 %%
(%%) :: forall k is js ks s t u v a b. AppendIndices is js ks
=> Optic k is s t u v
-> Optic k js u v a b
-> Optic k ks s t a b
Optic forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ k p i (Curry is i) s t u v
o %% :: forall k (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a b.
AppendIndices is js ks =>
Optic k is s t u v -> Optic k js u v a b -> Optic k ks s t a b
%% Optic forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ k p i (Curry js i) u v a b
o' = forall k (is :: IxList) s t a b.
(forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ k p i (Curry is i) s t a b)
-> Optic k is s t a b
Optic forall (p :: * -> * -> * -> *) i.
(Profunctor p, Constraints k p) =>
Optic__ p i (Curry ks i) s t a b
oo
where
oo :: forall p i. (Profunctor p, Constraints k p)
=> Optic__ p i (Curry ks i) s t a b
oo :: forall (p :: * -> * -> * -> *) i.
(Profunctor p, Constraints k p) =>
Optic__ p i (Curry ks i) s t a b
oo | IxEq i (Curry is (Curry js i)) (Curry ks i)
IxEq <- forall (xs :: IxList) (ys :: IxList) (ks :: IxList) i.
AppendIndices xs ys ks =>
IxEq i (Curry xs (Curry ys i)) (Curry ks i)
appendIndices @is @js @ks @i = forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ k p i (Curry is i) s t u v
o forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> * -> *) i.
Profunctor p =>
Optic_ k p i (Curry js i) u v a b
o'
{-# INLINE (%%) #-}
infixl 9 %&
(%&) :: Optic k is s t a b
-> (Optic k is s t a b -> Optic l js s' t' a' b')
-> Optic l js s' t' a' b'
%& :: forall k (is :: IxList) s t a b l (js :: IxList) s' t' a' b'.
Optic k is s t a b
-> (Optic k is s t a b -> Optic l js s' t' a' b')
-> Optic l js s' t' a' b'
(%&) = forall a b. a -> (a -> b) -> b
(&)
{-# INLINE (%&) #-}