Skip to content

Commit 6b71397

Browse files
Some strong monoidal action action
1 parent e23c508 commit 6b71397

File tree

24 files changed

+187
-160
lines changed

24 files changed

+187
-160
lines changed

src/Proarrow/Category/Instance/Cat.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import Proarrow.Object.Exponential (Closed (..))
3838
import Proarrow.Object.Initial (HasInitialObject (..))
3939
import Proarrow.Object.Terminal (HasTerminalObject (..))
4040
import Proarrow.Profunctor.Composition ((:.:))
41-
import Proarrow.Profunctor.Identity (Id)
41+
import Proarrow.Profunctor.Identity (Id (..))
4242
import Proarrow.Profunctor.Representable (Rep, Representable (..))
4343

4444
newtype KIND = K Kind
@@ -232,8 +232,8 @@ instance MonoidalAction KIND KIND where
232232
multiplicator = associatorInv
233233
multiplicatorInv = associator
234234

235-
instance Strong KIND Cat where
236-
act = par
235+
instance Strong KIND (Id :: CAT KIND) where
236+
act = par . Id
237237

238238
instance Costrong KIND Cat where
239239
coact @u = compactClosedCoact @u

src/Proarrow/Category/Instance/Kleisli.hs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ module Proarrow.Category.Instance.Kleisli
1111
, pattern LiftF
1212
) where
1313

14+
import Data.Kind (Type)
15+
1416
import Proarrow.Adjunction (Proadjunction)
1517
import Proarrow.Adjunction qualified as Adj
1618
import Proarrow.Category.Monoidal (Monoidal (..), MonoidalProfunctor (..), SymMonoidal (..))
@@ -38,6 +40,7 @@ import Proarrow.Profunctor.Representable (RepCostar(..), Representable(..), triv
3840
import Proarrow.Monoid (CopyDiscard (..))
3941
import Proarrow.Category.Enriched.ThinCategory qualified as T
4042
import Proarrow.Category.Enriched.Dagger (DaggerProfunctor (..))
43+
import Proarrow.Profunctor.Identity (Id (..))
4144

4245
newtype KLEISLI (p :: CAT k) = KL k
4346
type instance UN KL (KL k) = k
@@ -115,15 +118,15 @@ instance (Distributive k, Promonad p, DistributiveProfunctor p) => Distributive
115118
distL0 @(KL a) = arr (distL0 @k @a)
116119
distR0 @(KL a) = arr (distR0 @k @a)
117120

118-
instance (Strong k p, Promonad p, Monoidal k) => Strong k (Kleisli :: CAT (KLEISLI (p :: k +-> k))) where
119-
act f (Kleisli p) = Kleisli (act f p)
120-
instance (Strong k p, Promonad p, Monoidal k) => MonoidalAction k (KLEISLI (p :: k +-> k)) where
121+
instance (Strong Type p, Promonad p) => Strong Type (Id :: CAT (KLEISLI (p :: Type +-> Type))) where
122+
act f (Id (Kleisli p)) = Id (Kleisli (act f p))
123+
instance (Strong Type p, Promonad p) => MonoidalAction Type (KLEISLI (p :: Type +-> Type)) where
121124
type Act y (KL x) = KL (Act y x)
122-
withObAct @y @(KL x) r = withObAct @k @k @y @x r
123-
unitor = arr (unitor @k)
124-
unitorInv = arr (unitorInv @k)
125-
multiplicator @a @b @(KL c) = arr (multiplicator @k @k @a @b @c)
126-
multiplicatorInv @a @b @(KL c) = arr (multiplicatorInv @k @k @a @b @c)
125+
withObAct @y @(KL x) r = withObAct @Type @Type @y @x r
126+
unitor = arr (unitor @Type)
127+
unitorInv = arr (unitorInv @Type)
128+
multiplicator @a @b @(KL c) = arr (multiplicator @Type @Type @a @b @c)
129+
multiplicatorInv @a @b @(KL c) = arr (multiplicatorInv @Type @Type @a @b @c)
127130

128131
instance (DaggerProfunctor p, Promonad p) => DaggerProfunctor (Kleisli :: CAT (KLEISLI p)) where
129132
dagger (Kleisli p) = Kleisli (dagger p)

src/Proarrow/Category/Instance/Linear.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Proarrow.Category.Monoidal.Action (Costrong (..))
1212
import Proarrow.Core (CAT, CategoryOf (..), Is, Profunctor (..), Promonad (..), UN, dimapDefault, type (+->))
1313
import Proarrow.Functor (Functor (..), FunctorForRep (..))
1414
import Proarrow.Monoid (Comonoid (..))
15-
import Proarrow.Object.BinaryCoproduct (COPROD, Coprod (..), HasBinaryCoproducts (..))
15+
import Proarrow.Object.BinaryCoproduct (COPROD, HasBinaryCoproducts (..))
1616
import Proarrow.Object.BinaryProduct (HasBinaryProducts (..))
1717
import Proarrow.Object.Copower (Copowered (..))
1818
import Proarrow.Object.Dual (StarAutonomous (..))
@@ -22,7 +22,6 @@ import Proarrow.Object.Power (Powered (..))
2222
import Proarrow.Object.Terminal (HasTerminalObject (..))
2323
import Proarrow.Profunctor.Composition ((:.:) (..))
2424
import Proarrow.Profunctor.Corepresentable (Corep (..), Corepresentable (..))
25-
import Proarrow.Profunctor.Identity (Id (..))
2625
import Proarrow.Profunctor.Representable (Rep (..))
2726
import System.IO.Unsafe (unsafeDupablePerformIO)
2827
import Unsafe.Coerce (unsafeCoerce)
@@ -127,8 +126,8 @@ instance HasInitialObject LINEAR where
127126
type InitialObject = L Void
128127
initiate = Linear \case {}
129128

130-
instance Costrong (COPROD LINEAR) (Coprod (Id :: CAT LINEAR)) where
131-
coact (Coprod (Id (Linear uxuy))) = Coprod (Id (loop . Linear Right))
129+
instance Costrong (COPROD LINEAR) Linear where
130+
coact (Linear uxuy) = loop . Linear Right
132131
where
133132
loop = Linear \ux -> case uxuy ux of Left x -> unLinear loop (Left x); Right b -> b
134133

src/Proarrow/Category/Instance/Mat.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Proarrow.Object.Dual
2525
import Proarrow.Object.Exponential (Closed (..))
2626
import Proarrow.Object.Initial (HasInitialObject (..))
2727
import Proarrow.Object.Terminal (HasTerminalObject (..))
28+
import Proarrow.Profunctor.Identity (Id(..))
2829

2930
type data Nat = Z | S Nat
3031

@@ -224,8 +225,8 @@ instance (P.Num a) => MonoidalAction (MatK a) (MatK a) where
224225
multiplicator @(M b) @(M c) @(M d) = withAssocMult @d @c @b (obj @(M b) `par` (obj @(M c) `par` obj @(M d)))
225226
multiplicatorInv @(M b) @(M c) @(M d) = withAssocMult @d @c @b (obj @(M b) `par` (obj @(M c) `par` obj @(M d)))
226227

227-
instance (P.Num a) => Strong (MatK a) (Mat :: CAT (MatK a)) where
228-
act = par
228+
instance (P.Num a) => Strong (MatK a) (Id :: CAT (MatK a)) where
229+
act = par . Id
229230

230231
instance (P.Num a) => Costrong (MatK a) (Mat :: CAT (MatK a)) where
231232
coact @x = compactClosedCoact @x

src/Proarrow/Category/Instance/Nat.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import Proarrow.Object.Initial (HasInitialObject (..))
2727
import Proarrow.Object.Power (Powered (..))
2828
import Proarrow.Object.Terminal (HasTerminalObject (..))
2929
import Proarrow.Profunctor.Composition ((:.:) (..))
30+
import Proarrow.Profunctor.Identity (Id (..))
3031

3132
type Nat :: CAT (j -> k)
3233
data Nat f g where
@@ -114,8 +115,8 @@ instance Monoidal (Type -> Type) where
114115
associator = Nat (Compose . map Compose . getCompose . getCompose)
115116
associatorInv = Nat (Compose . Compose . map getCompose . getCompose)
116117

117-
instance Strong (Type -> Type) (->) where
118-
act (Nat n) f = n . map f
118+
instance Strong (Type -> Type) (Id :: CAT Type) where
119+
act (Nat n) (Id f) = Id (n . map f)
119120
instance MonoidalAction (Type -> Type) Type where
120121
type Act (p :: Type -> Type) (x :: Type) = p x
121122
withObAct r = r

src/Proarrow/Category/Instance/Sub.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Proarrow.Functor (FunctorForRep (..))
1010
import Proarrow.Monoid (CopyDiscard (..))
1111
import Proarrow.Profunctor.Corepresentable (Corepresentable)
1212
import Proarrow.Profunctor.Representable (Representable (..))
13+
import Proarrow.Profunctor.Identity (Id)
1314

1415
type SUBCAT :: forall {k}. OB k -> Type
1516
type data SUBCAT (ob :: OB k) = SUB k
@@ -70,11 +71,11 @@ instance (Representable p, forall a. (ob a) => ob (p % a)) => Representable (Sub
7071
tabulate (Sub f) = Sub (tabulate f)
7172
repMap (Sub f) = Sub (repMap @p f)
7273

73-
instance (MonoidalAction m Type, Monoidal (SUBCAT (ob :: OB m))) => Strong (SUBCAT (ob :: OB m)) (->) where
74+
instance (MonoidalAction m k, Monoidal (SUBCAT (ob :: OB m))) => Strong (SUBCAT (ob :: OB m)) (Id :: CAT k) where
7475
Sub f `act` g = f `act` g
75-
instance (MonoidalAction m Type, Monoidal (SUBCAT (ob :: OB m))) => MonoidalAction (SUBCAT (ob :: OB m)) Type where
76-
type Act (p :: SUBCAT ob) (x :: Type) = Act (UN SUB p) x
77-
withObAct r = r
76+
instance (MonoidalAction m k, Monoidal (SUBCAT (ob :: OB m))) => MonoidalAction (SUBCAT (ob :: OB m)) k where
77+
type Act (p :: SUBCAT ob) (x :: k) = Act (UN SUB p) x
78+
withObAct @(SUB a) @x r = withObAct @m @k @a @x r
7879
unitor = unitor @m
7980
unitorInv = unitorInv @m
8081
multiplicator @(SUB p) @(SUB q) @x = multiplicator @_ @_ @p @q @x

src/Proarrow/Category/Monoidal/Action.hs

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ module Proarrow.Category.Monoidal.Action where
55
import Data.Kind (Constraint)
66
import Prelude (type (~))
77

8+
import Proarrow.Category.Instance.Product ((:**:) (..))
9+
import Proarrow.Category.Instance.Unit qualified as U
810
import Proarrow.Category.Monoidal (Monoidal (..), MonoidalProfunctor (..), SymMonoidal (..))
911
import Proarrow.Core (CAT, CategoryOf (..), Kind, Profunctor (..), Promonad (..), obj, type (+->))
10-
import Proarrow.Category.Instance.Product ((:**:) (..))
12+
import Proarrow.Profunctor.Identity (Id (..))
13+
import Proarrow.Profunctor.Representable (Representable (..), trivialRep)
14+
import Proarrow.Profunctor.Corepresentable (Corepresentable(..), trivialCorep)
1115

1216
-- | Profuntorial strength for a monoidal action.
1317
-- Gives functorial strength for representable profunctors,
@@ -16,9 +20,16 @@ type Strong :: forall {j} {k}. Kind -> j +-> k -> Constraint
1620
class (MonoidalAction m c, MonoidalAction m d, Profunctor p) => Strong m (p :: c +-> d) where
1721
act :: forall (a :: m) b x y. a ~> b -> p x y -> p (Act a x) (Act b y)
1822

23+
actHom :: (MonoidalAction m k) => (a :: m) ~> b -> (x :: k) ~> y -> Act a x ~> Act b y
24+
actHom ab xy = unId (act ab (Id xy))
25+
26+
instance (Profunctor p) => Strong () p where
27+
act U.Unit p = p
28+
1929
instance (Strong m p, Strong m' q) => Strong (m, m') (p :**: q) where
2030
act (p :**: q) (x :**: y) = act p x :**: act q y
21-
class (Monoidal m, CategoryOf k, Strong m ((~>) :: CAT k)) => MonoidalAction m k where
31+
32+
class (Monoidal m, CategoryOf k, Strong m (Id :: CAT k)) => MonoidalAction m k where
2233
-- I would like to default Act to `**`, but that doesn't seem possible without GHC thinking `m` and `k` are the same.
2334
type Act (a :: m) (x :: k) :: k
2435
withObAct :: (Ob (a :: m), Ob (x :: k)) => ((Ob (Act a x)) => r) -> r
@@ -27,6 +38,17 @@ class (Monoidal m, CategoryOf k, Strong m ((~>) :: CAT k)) => MonoidalAction m k
2738
multiplicator :: (Ob (a :: m), Ob (b :: m), Ob (x :: k)) => Act a (Act b x) ~> Act (a ** b) x
2839
multiplicatorInv :: (Ob (a :: m), Ob (b :: m), Ob (x :: k)) => Act (a ** b) x ~> Act a (Act b x)
2940

41+
instance (CategoryOf k) => MonoidalAction () k where
42+
type Act '() x = x
43+
withObAct r = r
44+
unitor = id
45+
unitorInv = id
46+
multiplicator = id
47+
multiplicatorInv = id
48+
49+
instance (Strong m (Id :: CAT p), Strong n (Id :: CAT q)) => Strong (m, n) (Id :: CAT (p, q)) where
50+
act (f :**: f') (Id (g :**: g')) = Id (actHom f g :**: actHom f' g')
51+
3052
instance (MonoidalAction n j, MonoidalAction m k) => MonoidalAction (n, m) (j, k) where
3153
type Act '(p, q) '(x, y) = '(Act p x, Act q y)
3254
withObAct @'(p, q) @'(x, y) r = withObAct @n @j @p @x (withObAct @m @k @q @y r)
@@ -35,7 +57,6 @@ instance (MonoidalAction n j, MonoidalAction m k) => MonoidalAction (n, m) (j, k
3557
multiplicator @'(p, q) @'(r, s) @'(x, y) = multiplicator @n @j @p @r @x :**: multiplicator @m @k @q @s @y
3658
multiplicatorInv @'(p, q) @'(r, s) @'(x, y) = multiplicatorInv @n @j @p @r @x :**: multiplicatorInv @m @k @q @s @y
3759

38-
3960
class (MonoidalAction m k, SymMonoidal m) => SymMonoidalAction m k
4061
instance (MonoidalAction m k, SymMonoidal m) => SymMonoidalAction m k
4162

@@ -57,37 +78,46 @@ instance
5778
=> SelfAction k
5879

5980
toSelfAct :: forall {k} (a :: k) b. (SelfAction k, Ob a, Ob b) => a ** b ~> Act a b
60-
toSelfAct = obj @a `act` obj @b
81+
toSelfAct = unId (obj @a `act` Id (obj @b))
6182

6283
fromSelfAct :: forall {k} (a :: k) b. (SelfAction k, Ob a, Ob b) => Act a b ~> a ** b
63-
fromSelfAct = obj @a `act` obj @b
84+
fromSelfAct = unId (obj @a `act` Id (obj @b))
6485

6586
composeActs
6687
:: forall {m} {k} (x :: m) y (c :: k) a b
6788
. (MonoidalAction m k, Ob x, Ob y, Ob c)
6889
=> a ~> Act x b
6990
-> b ~> Act y c
7091
-> a ~> Act (x ** y) c
71-
composeActs f g = multiplicator @m @k @x @y @c . act (obj @x) g . f
92+
composeActs f g = multiplicator @m @k @x @y @c . actHom (obj @x) g . f
7293

7394
decomposeActs
7495
:: forall {m} {k} (x :: m) y (c :: k) a b
7596
. (MonoidalAction m k, Ob x, Ob y, Ob c)
7697
=> Act y c ~> b
7798
-> Act x b ~> a
7899
-> Act (x ** y) c ~> a
79-
decomposeActs f g = g . act (obj @x) f . multiplicatorInv @m @k @x @y @c
100+
decomposeActs f g = g . actHom (obj @x) f . multiplicatorInv @m @k @x @y @c
80101

81102
first' :: forall {k} {p :: CAT k} c a b. (SelfAction k, Strong k p, Ob c) => p a b -> p (a ** c) (b ** c)
82103
first' p = dimap (swap @k @a @c) (swap @k @c @b) (second' @c p) \\ p
83104

84105
second' :: forall {k} {p :: CAT k} c a b. (SelfAction k, Strong k p, Ob c) => p a b -> p (c ** a) (c ** b)
85106
second' p = act (obj @c) p
86107

108+
-- | If a strong profunctor is representable, we get the usual strength for the represented functor.
109+
strength :: forall {m} p a b. (Representable p, Strong m p, Ob (a :: m), Ob b) => Act a (p % b) ~> p % Act a b
110+
strength = index (act (obj @a) (trivialRep @p @b))
111+
112+
-- | If a strong profunctor is corepresentable, we get the usual costrength for the represented functor.
113+
costrength :: forall {m} p a b. (Corepresentable p, Strong m p, Ob (a :: m), Ob b) => p %% Act a b ~> Act a (p %% b)
114+
costrength = coindex (act (obj @a) (trivialCorep @p @b))
115+
87116
-- | This is not monoidal `par` but premonoidal, i.e. no sliding.
88117
-- So with `prepar f g` the effects of f happen before the effects of g.
89118
-- p needs to be a commutative promonad for this to be monoidal `par`.
90-
prepar :: forall {k} {p :: CAT k} a b c d. (SelfAction k, Strong k p, Promonad p) => p a b -> p c d -> p (a ** c) (b ** d)
119+
prepar
120+
:: forall {k} {p :: CAT k} a b c d. (SelfAction k, Strong k p, Promonad p) => p a b -> p c d -> p (a ** c) (b ** d)
91121
prepar f g = second' @b g . first' @c f \\ f \\ g
92122

93123
strongPar0 :: forall {k} {p :: CAT k} a. (SelfAction k, Strong k p, MonoidalProfunctor p, Ob a) => p a a

src/Proarrow/Category/Monoidal/Optic.hs

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
{-# LANGUAGE AllowAmbiguousTypes #-}
22
{-# LANGUAGE IncoherentInstances #-}
3-
{-# OPTIONS_GHC -Wno-orphans #-}
3+
{-# OPTIONS_GHC -Wno-orphans -fprint-potential-instances #-}
44

55
module Proarrow.Category.Monoidal.Optic where
66

77
import Data.Bifunctor (bimap)
88
import Data.Kind (Type)
9-
import Prelude (Either, Maybe (..), Monad (..), Traversable, const, either, fmap, fst, snd, uncurry, ($), type (~))
9+
import Prelude (Either (..), Maybe (..), Monad (..), Traversable, const, either, fmap, uncurry, ($), type (~))
1010

1111
import Proarrow.Category.Instance.Kleisli (KLEISLI (..), Kleisli (..))
1212
import Proarrow.Category.Instance.Nat ((!))
13-
import Proarrow.Category.Instance.Product ((:**:) (..))
1413
import Proarrow.Category.Instance.Sub (SUBCAT (..), Sub (..))
1514
import Proarrow.Category.Monoidal (MonoidalProfunctor (..), SymMonoidal, swap)
16-
import Proarrow.Category.Monoidal.Action (MonoidalAction (..), Strong (..), composeActs, decomposeActs)
15+
import Proarrow.Category.Monoidal.Action (MonoidalAction (..), Strong (..), composeActs, decomposeActs, actHom)
1716
import Proarrow.Category.Opposite (OPPOSITE (..))
1817
import Proarrow.Core (CAT, CategoryOf (..), Kind, Profunctor (..), Promonad (..), dimapDefault, obj, type (+->))
18+
import Proarrow.Core qualified as Core
1919
import Proarrow.Functor (Prelude (..))
2020
import Proarrow.Object (src, tgt)
2121
import Proarrow.Object.BinaryCoproduct (COPROD (..), Coprod (..))
22-
import Proarrow.Object.BinaryProduct ()
22+
import Proarrow.Object.BinaryProduct (Cartesian, HasBinaryProducts (..))
23+
import Proarrow.Profunctor.Identity (Id (..))
2324
import Proarrow.Profunctor.Star (Star, pattern Star)
24-
import Proarrow.Profunctor.Identity (Id(..))
2525

2626
type Optic :: Kind -> c -> d -> c -> d -> Type
2727
data Optic m a b s t where
@@ -42,13 +42,10 @@ instance (CategoryOf c, CategoryOf d) => Profunctor (Optic m a b :: c +-> d) whe
4242
instance (IsOptic m c d) => Strong m (Optic m a b :: c +-> d) where
4343
act :: forall (a1 :: m) (b1 :: m) (s :: d) (t :: c). a1 ~> b1 -> Optic m a b s t -> Optic m a b (Act a1 s) (Act b1 t)
4444
act w (Optic @x @x' f w' g) =
45-
Optic (composeActs @a1 @x @a (src w `act` src f) f) (w `par` w') (decomposeActs @b1 @x' @b g (tgt w `act` tgt g))
45+
Optic (composeActs @a1 @x @a (src w `actHom` src f) f) (w `par` w') (decomposeActs @b1 @x' @b g (tgt w `actHom` tgt g))
4646
\\ w
4747
\\ w'
4848

49-
parallel :: Optic m a b s t -> Optic m' c d u v -> Optic (m, m') '(a, c) '(b, d) '(s, u) '(t, v)
50-
parallel (Optic f w g) (Optic h w' i) = Optic (f :**: h) (w :**: w') (g :**: i)
51-
5249
type data OPTIC m (c :: Kind) (d :: Kind) = OPT c d
5350
type family OptL (p :: OPTIC w c d) where
5451
OptL (OPT c d) = c
@@ -64,30 +61,36 @@ instance (IsOptic m c d) => Profunctor (OpticCat :: CAT (OPTIC m c d)) where
6461
instance (IsOptic m c d) => Promonad (OpticCat :: CAT (OPTIC m c d)) where
6562
id = OpticCat (prof2ex id)
6663
OpticCat l@Optic{} . OpticCat r@Optic{} = OpticCat $ prof2ex (ex2prof l . ex2prof r)
64+
6765
-- | The category of optics.
6866
instance (IsOptic m c d) => CategoryOf (OPTIC m c d) where
6967
type (~>) = OpticCat
7068
type Ob a = (a ~ OPT (OptL a) (OptR a), Ob (OptL a), Ob (OptR a))
7169

72-
type MixedOptic m a b s t = forall p. (Strong m p) => p a b -> p s t
70+
type MixedOptic m a b s t = Core.Optic (Strong m) s t a b
71+
72+
toIso :: MixedOptic () a b s t -> Core.Iso s t a b
73+
toIso l p = l p
7374

7475
ex2prof :: forall m a b s t. Optic m a b s t -> MixedOptic m a b s t
7576
ex2prof (Optic l w r) p = dimap l r (act w p)
7677

7778
prof2ex
78-
:: forall {c} {d} m a b s t
79+
:: forall {c} {d} m (a :: c) (b :: d) (s :: c) (t :: d)
7980
. (MonoidalAction m c, MonoidalAction m d, Ob a, Ob b)
80-
=> MixedOptic m (a :: c) (b :: d) (s :: c) (t :: d)
81+
=> MixedOptic m a b s t
8182
-> Optic m a b s t
8283
prof2ex p2p = p2p (Optic (unitorInv @m) par0 (unitor @m))
8384

84-
type Lens s t a b = MixedOptic Type a b s t
85-
mkLens :: (s -> a) -> (s -> b -> t) -> Lens s t a b
86-
mkLens sa sbt = ex2prof (Optic (\s -> (s, sa s)) (src sa) (uncurry sbt))
85+
type Lens (s :: k) t a b = MixedOptic k a b s t
86+
mkLens
87+
:: (Cartesian k, Act s a ~ (s && a), Act s b ~ (s && b), Ob (b :: k))
88+
=> (s ~> a) -> ((s && b) ~> t) -> Lens s t a b
89+
mkLens sa sbt = ex2prof (Optic (id &&& sa) (src sa) sbt) \\ sa
8790

88-
type Prism s t a b = MixedOptic (COPROD Type) (COPR a) (COPR b) (COPR s) (COPR t)
91+
type Prism (s :: k) t a b = MixedOptic (COPROD k) a b s t
8992
mkPrism :: (s -> Either t a) -> (b -> t) -> Prism s t a b
90-
mkPrism sat bt = ex2prof @(COPROD Type) (Optic (Coprod (Id sat)) id (Coprod (Id (either id bt))))
93+
mkPrism sta bt = ex2prof @(COPROD Type) (Optic sta id (either id bt))
9194

9295
type Traversal s t a b = MixedOptic (SUBCAT Traversable) a b s t
9396
traversing :: (Traversable f) => Traversal (f a) (f b) a b
@@ -113,10 +116,10 @@ infixl 8 ^.
113116
(^.) :: s -> (Viewing a b a b -> Viewing a b s t) -> a
114117
(^.) s l = unView (l $ Viewing id) s
115118

116-
data Previewing a (b :: COPROD Type) s (t :: COPROD Type) where
117-
Previewing :: {unPreview :: s -> Maybe a} -> Previewing (COPR a) (COPR b) (COPR s) (COPR t)
119+
data Previewing a (b :: Type) s (t :: Type) where
120+
Previewing :: {unPreview :: s -> Maybe a} -> Previewing a b s t
118121
instance Profunctor (Previewing a b) where
119-
dimap (Coprod (Id l)) Coprod{} (Previewing f) = Previewing (f . l)
122+
dimap l _ (Previewing f) = Previewing (f . l)
120123
r \\ Previewing f = r \\ f
121124
instance Strong (COPROD Type) (Previewing a b) where
122125
act _ (Previewing f) = Previewing (either (const Nothing) f)
@@ -125,7 +128,7 @@ instance Strong Type (Previewing a b) where
125128

126129
infixl 8 ?.
127130
(?.)
128-
:: s -> (Previewing (COPR a) (COPR b) (COPR a) (COPR b) -> Previewing (COPR a) (COPR b) (COPR s) (COPR t)) -> Maybe a
131+
:: s -> (Previewing a b a b -> Previewing a b s t) -> Maybe a
129132
(?.) s l = unPreview (l $ Previewing Just) s
130133

131134
type KlCat m = KLEISLI (Star (Prelude m))
@@ -193,9 +196,10 @@ instance (IsChart m c d) => Promonad (ChartCat :: CAT (CHART m c d)) where
193196
id = ChartCat (prof2ex id)
194197
ChartCat (Optic @x @x' @_ @t ll lw lr) . ChartCat (Optic @y @y' @a rl rw rr) =
195198
ChartCat $
196-
Optic (composeActs @x @y @a ll rl) (lw `par` rw) (decomposeActs @y' @x' @t lr rr . (swap @_ @x' @y' `act` obj @t))
199+
Optic (composeActs @x @y @a ll rl) (lw `par` rw) (decomposeActs @y' @x' @t lr rr . (swap @_ @x' @y' `actHom` obj @t))
197200
\\ lw
198201
\\ rw
202+
199203
-- | The category of charts.
200204
instance (IsChart m c d) => CategoryOf (CHART m c d) where
201205
type (~>) = ChartCat

0 commit comments

Comments
 (0)