| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Proarrow.Optic.PowerGrate
Contents
Description
A power grate is a Grate whose exponent is a fixed tensor power of
the focus: the witness presents Pow ns as a ** ... ** a (n times), i.e. the exponential
by a finite arity, which is also the reader applicative for n readers. That fixed, finite shape
is a genuine decomposition, so a power grate is also a __fixed-arity
Traversal__ ():
it zips, aggregates, folds, sets and traverses like those do.PowerGrateFl <: GrateFl, KaleidoFl, MonTravFl
Its distinctive power over a grate or kaleidoscope is the eliminator: powerGrateP distributes
an arbitrary MonoidalProfunctor -- the Applicative/zip structure (one and **) alone --
rather than the full StrongDistributiveProfunctor a
traversal needs or the traversable carrier a kaleidoscope needs. With a fixed arity, any functor
carrier Costar f distributes, by unzipping f (a ** ... ** a) into f a ** ... ** f a.
The aggregation is stated over an abstract , not the Hask-specific
MonoidalProfunctor rCostar f = f a -> b: powerGrateOf works at any monoidal profunctor carrier (the hom (
gives ~>)over; an applicative
combines the foci through Star ff).
Synopsis
- class (MonTravFl p q, GrateFl p q) => PowerGrateFl (p :: k +-> k) (q :: k +-> k) where
- powerGrateP :: forall r (s :: k) (a :: k) (b :: k) (t :: k). MonoidalProfunctor r => p s a -> q b t -> r a b -> r s t
- type PowerGrate (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (PowerGrateFl :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b
- type PowerGrate' (s :: k) (a :: k) = PowerGrate s s a a
- powerGrateOf :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k) r. (Monoidal k, MonoidalProfunctor r, (Ob a, Ob b) => c (ExOptic (PowerGrateFl :: (k +-> k) -> (k +-> k) -> Constraint) a b)) => Optic c s t a b -> r a b -> r s t
- zipWithOf :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k). (Monoidal k, Ob a, (Ob a, Ob b) => c (ExOptic (KaleidoFl :: (k +-> k) -> (k +-> k) -> Constraint) a b)) => Optic c s t a b -> ((a ** a) ~> b) -> (s ** s) ~> t
- data Nat
- type family Tensor (n :: Nat) (a :: k) :: k where ...
- class KnownNat (n :: Nat) where
- data Pow (n :: Nat) (s :: k) (a :: k) where
- data CoPow (n :: Nat) (b :: k) (t :: k) where
- powerGrate :: forall {k} (n :: Nat) (s :: k) (t :: k) (a :: k) (b :: k). (CopyDiscard k, HasCoproducts k, KnownNat n, Ob a, Ob b) => (s ~> Tensor n a) -> (Tensor n b ~> t) -> PowerGrate s t a b
Documentation
class (MonTravFl p q, GrateFl p q) => PowerGrateFl (p :: k +-> k) (q :: k +-> k) where Source Github #
The power-grate flavor: distribute any MonoidalProfunctor r through the witness
pair. TravFl is a superclass: every power-grate witness is a
traversal witness (instantiate r at a StrongDistributiveProfunctor,
a special MonoidalProfunctor), so it folds, sets, and traverses. The extra power is
distributing the non-SDP monoidal profunctors as well. KaleidoFl
is a superclass too: a tensor power is an applicative functor (the reader applicative).
Methods
powerGrateP :: forall r (s :: k) (a :: k) (b :: k) (t :: k). MonoidalProfunctor r => p s a -> q b t -> r a b -> r s t Source Github #
Instances
| CategoryOf k => PowerGrateFl (Id :: k -> k -> Type) (Id :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate Methods powerGrateP :: forall r (s :: k) (a :: k) (b :: k) (t :: k). MonoidalProfunctor r => Id s a -> Id b t -> r a b -> r s t Source Github # | |
| (CopyDiscard k, HasCoproducts k, KnownNat n) => PowerGrateFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate Methods powerGrateP :: forall r (s :: k) (a :: k) (b :: k) (t :: k). MonoidalProfunctor r => Pow n s a -> CoPow n b t -> r a b -> r s t Source Github # | |
| (PowerGrateFl f g, PowerGrateFl f' g') => PowerGrateFl (f :.: f' :: i -> i -> Type) (g' :.: g :: i -> i -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate Methods powerGrateP :: forall r (s :: i) (a :: i) (b :: i) (t :: i). MonoidalProfunctor r => (f :.: f') s a -> (g' :.: g) b t -> r a b -> r s t Source Github # | |
type PowerGrate (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (PowerGrateFl :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b Source Github #
type PowerGrate' (s :: k) (a :: k) = PowerGrate s s a a Source Github #
powerGrateOf :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k) r. (Monoidal k, MonoidalProfunctor r, (Ob a, Ob b) => c (ExOptic (PowerGrateFl :: (k +-> k) -> (k +-> k) -> Constraint) a b)) => Optic c s t a b -> r a b -> r s t Source Github #
Distribute any MonoidalProfunctor through a power grate (or any stronger optic). At the
hom ( this is ~>)over; at an applicative the foci are
combined through Star ff.
Accepts any encoding (cf. traverseOf), including (%)-composites.
zipWithOf :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k). (Monoidal k, Ob a, (Ob a, Ob b) => c (ExOptic (KaleidoFl :: (k +-> k) -> (k +-> k) -> Constraint) a b)) => Optic c s t a b -> ((a ** a) ~> b) -> (s ** s) ~> t Source Github #
Zip two sources through a Kaleidoscope (or any stronger optic, a
Grate in particular, in any encoding): combine the foci pairwise. This is
kaleidoscopeOf at the carrier , the costar of the binary tensor power --
a binary combination RepCostar (Pow 2)(a ** a) ~> b of foci, which the optic's applicative lifts by liftA2.
n-ary aggregation
type family Tensor (n :: Nat) (a :: k) :: k where ... Source Github #
The n-fold tensor power of a: a ** a ** ... ** a (n times, terminated by Unit).
class KnownNat (n :: Nat) where Source Github #
Case analysis on a type-level Nat: the single method from which every tensor-power
operation below is defined by recursion on n.
Methods
natCase :: (n ~ 'Z => r) -> (forall (m :: Nat). (n ~ 'S m, KnownNat m) => r) -> r Source Github #
data Pow (n :: Nat) (s :: k) (a :: k) where Source Github #
The arity-n aggregation witness: s presents n foci via the tensor power.
Instances
| (CopyDiscard k, KnownNat n) => Strong (Tensor :: k -> (k, k) -> Type) (Pow n :: k -> k -> Type) Source Github # | |
| (SymMonoidal k, KnownNat n) => MonoidalProfunctor (Pow n :: k -> k -> Type) Source Github # | |
| (Monoidal k, KnownNat n) => Profunctor (Pow n :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate Methods dimap :: forall (c :: k) (a :: k) (b :: k) (d :: k). (c ~> a) -> (b ~> d) -> Pow n a b -> Pow n c d Source Github # lmap :: forall (c :: k) (a :: k) (b :: k). (c ~> a) -> Pow n a b -> Pow n c b Source Github # rmap :: forall (b :: k) (d :: k) (a :: k). (b ~> d) -> Pow n a b -> Pow n a d Source Github # (\\) :: forall (a :: k) (b :: k) r. ((Ob a, Ob b) => r) -> Pow n a b -> r Source Github # | |
| (Monoidal k, KnownNat n) => Representable (Pow n :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate Methods index :: forall (a :: k) (b :: k). Pow n a b -> a ~> ((Pow n :: k -> k -> Type) % b) Source Github # tabulate :: forall (b :: k) (a :: k). Ob b => (a ~> ((Pow n :: k -> k -> Type) % b)) -> Pow n a b Source Github # repMap :: forall (a :: k) (b :: k). (a ~> b) -> ((Pow n :: k -> k -> Type) % a) ~> ((Pow n :: k -> k -> Type) % b) Source Github # repUniv :: forall (a :: k). Ob a => Pow n ((Pow n :: k -> k -> Type) % a) a Source Github # | |
| (Monoidal k, KnownNat n) => Proadjunction (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
| (Monoidal k, KnownNat n) => FoldFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
| (Monoidal k, KnownNat n) => Traversable (Pow n :: k -> k -> Type) Source Github # |
|
| (Monoidal k, HasCoproducts k, KnownNat n) => GlassFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | A power grate is a glass: ignore the source, and for each of the |
| (CopyDiscard k, HasCoproducts k, KnownNat n) => GrateFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
| (CopyDiscard k, HasCoproducts k, KnownNat n) => CotravFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate | |
| (CopyDiscard k, HasCoproducts k, KnownNat n) => KaleidoFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate | |
| (CopyDiscard k, HasCoproducts k, KnownNat n) => PowerGrateFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate Methods powerGrateP :: forall r (s :: k) (a :: k) (b :: k) (t :: k). MonoidalProfunctor r => Pow n s a -> CoPow n b t -> r a b -> r s t Source Github # | |
| (Monoidal k, KnownNat n) => SetterFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
| (Monoidal k, KnownNat n) => MonTravFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate | |
| (Monoidal k, KnownNat n) => TravFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate | |
| (CopyDiscard k, HasCoproducts k, KnownNat n) => Strong (CoprodAction :: k -> (COPROD k, k) -> Type) (Pow n :: k -> k -> Type) Source Github # | |
| (SymMonoidal k, HasCoproducts k, KnownNat n) => MonoidalProfunctor (Coprod (Pow n :: k -> k -> Type) :: COPROD k -> COPROD k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate Methods one :: Coprod (Pow n :: k -> k -> Type) (Unit :: COPROD k) (Unit :: COPROD k) Source Github # (**) :: forall (x1 :: COPROD k) (x2 :: COPROD k) (y1 :: COPROD k) (y2 :: COPROD k). Coprod (Pow n :: k -> k -> Type) x1 x2 -> Coprod (Pow n :: k -> k -> Type) y1 y2 -> Coprod (Pow n :: k -> k -> Type) (x1 ** y1) (x2 ** y2) Source Github # | |
| type (Pow n :: k -> k -> Type) % (a :: k) Source Github # | |
Defined in Proarrow.Optic.PowerGrate | |
data CoPow (n :: Nat) (b :: k) (t :: k) where Source Github #
The dual of Pow: t is rebuilt from n foci.
Constructors
| CoPow :: forall (n :: Nat) {k} (b :: k) (t :: k). Ob b => (Tensor n b ~> t) -> CoPow n b t |
Instances
| (Monoidal k, KnownNat n) => Profunctor (CoPow n :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate Methods dimap :: forall (c :: k) (a :: k) (b :: k) (d :: k). (c ~> a) -> (b ~> d) -> CoPow n a b -> CoPow n c d Source Github # lmap :: forall (c :: k) (a :: k) (b :: k). (c ~> a) -> CoPow n a b -> CoPow n c b Source Github # rmap :: forall (b :: k) (d :: k) (a :: k). (b ~> d) -> CoPow n a b -> CoPow n a d Source Github # (\\) :: forall (a :: k) (b :: k) r. ((Ob a, Ob b) => r) -> CoPow n a b -> r Source Github # | |
| (Monoidal k, KnownNat n) => Proadjunction (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
| (Monoidal k, KnownNat n) => FoldFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
| (Monoidal k, HasCoproducts k, KnownNat n) => GlassFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | A power grate is a glass: ignore the source, and for each of the |
| (CopyDiscard k, HasCoproducts k, KnownNat n) => GrateFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
| (CopyDiscard k, HasCoproducts k, KnownNat n) => CotravFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate | |
| (CopyDiscard k, HasCoproducts k, KnownNat n) => KaleidoFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate | |
| (CopyDiscard k, HasCoproducts k, KnownNat n) => PowerGrateFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate Methods powerGrateP :: forall r (s :: k) (a :: k) (b :: k) (t :: k). MonoidalProfunctor r => Pow n s a -> CoPow n b t -> r a b -> r s t Source Github # | |
| (Monoidal k, KnownNat n) => SetterFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
| (Monoidal k, KnownNat n) => MonTravFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate | |
| (Monoidal k, KnownNat n) => TravFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate | |
powerGrate :: forall {k} (n :: Nat) (s :: k) (t :: k) (a :: k) (b :: k). (CopyDiscard k, HasCoproducts k, KnownNat n, Ob a, Ob b) => (s ~> Tensor n a) -> (Tensor n b ~> t) -> PowerGrate s t a b Source Github #
Build an n-ary power grate from a tensor-power decomposition of s and recomposition
of t.