| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Proarrow.Optic.Setter
Contents
Description
The setter: the weakest write-side optic, applying a morphism to every focus (SetterRes
/ overP, whose Proadjunction superclass certifies the witness pair is a genuine adjoint
pair, i.e. the optic is lawful). It sits at the write-only top of the subtyping lattice
alongside Fold, so it has no builder of its own
(convert a stronger optic); its canonical eliminator is over -- with set,
(%~) and (.~) as shorthands -- via the hom carrier Id.
Synopsis
- class Proadjunction p q => SetterRes (p :: k +-> k) (q :: k +-> k) where
- type Setter (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (SetterRes :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b
- type Setter' (s :: k) (a :: k) = Setter s s a a
- over :: forall {k} (c :: (k +-> k) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k). c (Id :: k -> k -> Type) => Optic c s t a b -> (a ~> b) -> s ~> t
- (%~) :: forall (c :: (Type +-> Type) -> Constraint) s t a b. c (Id :: Type -> Type -> Type) => Optic c s t a b -> (a -> b) -> s -> t
- (.~) :: forall (c :: (Type +-> Type) -> Constraint) s t a b. c (Id :: Type -> Type -> Type) => Optic c s t a b -> b -> s -> t
- set :: forall (c :: (Type +-> Type) -> Constraint) s t a b. c (Id :: Type -> Type -> Type) => Optic c s t a b -> b -> s -> t
- mupdate :: Monad m => Setter ('KL s :: KLEISLI (Star (Prelude m))) ('KL t :: KLEISLI (Star (Prelude m))) ('KL a :: KLEISLI (Star (Prelude m))) ('KL b :: KLEISLI (Star (Prelude m))) -> b -> s -> m t
Documentation
class Proadjunction p q => SetterRes (p :: k +-> k) (q :: k +-> k) where Source Github #
A setter can only apply a pure function to the a's it can see -- it can neither view nor
fold them. A traversal is both a setter and a fold.
| The Proadjunction superclass certifies that a setter's witness pair is a genuine adjoint
pair -- the residual is an actual functor whose unit/counit round-trip -- i.e. the optic
is lawful.
Methods
overP :: forall (s :: k) (a :: k) (b :: k) (t :: k). p s a -> q b t -> (a ~> b) -> s ~> t Source Github #
Instances
| Representable t => SetterRes (t :: k +-> k) (RepCostar t :: k -> k -> Type) Source Github # | Every representable residual is a setter: map the focus through the residual functor with
|
| Monoidal k => SetterRes (Two :: k -> k -> Type) (CoTwo :: k -> k -> Type) Source Github # | |
| Monoidal k => SetterRes (UnitW :: k -> k -> Type) (CoUnitW :: k -> k -> Type) Source Github # | |
| HasInitialObject k => SetterRes (ZeroW :: k -> k -> Type) (CoZeroW :: k -> k -> Type) Source Github # | |
| CategoryOf k => SetterRes (Id :: k -> k -> Type) (Id :: k -> k -> Type) Source Github # | |
| (Monoidal k, KnownNat n) => SetterRes (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
| Comonoid m => SetterRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
| (Monoidal k, Ob a) => SetterRes (TensorW a :: k -> k -> Type) (CoTensorW a :: k -> k -> Type) Source Github # | |
| Corepresentable t => SetterRes (CorepStar t :: k -> k -> Type) (t :: k +-> k) Source Github # | Dually, every corepresentable residual is a setter: map with |
| (SetterRes p1 q1, SetterRes p2 q2, Monoidal k) => SetterRes (Beside p1 p2 :: k -> k -> Type) (CoBeside q1 q2 :: k -> k -> Type) Source Github # | |
| (SetterRes p1 q1, SetterRes p2 q2, HasBinaryCoproducts k) => SetterRes (BesideSum p1 p2 :: k -> k -> Type) (CoBesideSum q1 q2 :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.Traversal | |
| (Closed k, Ob m) => SetterRes (Rep (Exp m) :: k -> k -> Type) (Corep (Exp m) :: k -> k -> Type) Source Github # | The grate witness is a setter witness: map under the exponential. The |
| (HasCoproducts k, Ob t) => SetterRes (Rep (Coproduct t) :: k -> k -> Type) (Corep (Coproduct t) :: k -> k -> Type) Source Github # | |
| (HasBinaryProducts k, Ob s) => SetterRes (Rep (Product s) :: k -> k -> Type) (Corep (Product s) :: k -> k -> Type) Source Github # | |
| (SetterRes f g, SetterRes f' g') => SetterRes (f :.: f' :: i -> i -> Type) (g' :.: g :: i -> i -> Type) Source Github # | |
type Setter (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (SetterRes :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b Source Github #
over :: forall {k} (c :: (k +-> k) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k). c (Id :: k -> k -> Type) => Optic c s t a b -> (a ~> b) -> s ~> t Source Github #
(%~) :: forall (c :: (Type +-> Type) -> Constraint) s t a b. c (Id :: Type -> Type -> Type) => Optic c s t a b -> (a -> b) -> s -> t infixl 8 Source Github #
Apply a function through a concrete, Type-level Setter.
(.~) :: forall (c :: (Type +-> Type) -> Constraint) s t a b. c (Id :: Type -> Type -> Type) => Optic c s t a b -> b -> s -> t infixl 8 Source Github #
Replace the focus/foci of a concrete, Type-level Setter with a constant value.
set :: forall (c :: (Type +-> Type) -> Constraint) s t a b. c (Id :: Type -> Type -> Type) => Optic c s t a b -> b -> s -> t Source Github #
Named version of (.~).
mupdate :: Monad m => Setter ('KL s :: KLEISLI (Star (Prelude m))) ('KL t :: KLEISLI (Star (Prelude m))) ('KL a :: KLEISLI (Star (Prelude m))) ('KL b :: KLEISLI (Star (Prelude m))) -> b -> s -> m t Source Github #
Monadically replace the focus/foci of a Setter in the Kleisli category of m with a
constant value, ignoring the old contents entirely.