| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Proarrow.Optic.Lens
Description
The lens: the optic for the categorical product, with legs
Lens s t a b = (s ~> a, (s && b) ~> t)
witnessed by /RepCorep( (Product s)LensRes / putP) -- the product residual is
the whole source s. A lens both views and sets, sitting below Getter
and AffineTraversal in the lattice. Build with lens (or from
the van-Laarhoven form with lensVL), eliminate to the two legs with withLens, via the
Shop carrier.
Synopsis
- class (AffineTravRes p q, GetterRes p q) => LensRes (p :: k +-> k) (q :: k +-> k) where
- putP :: forall (s :: k) (a :: k) (b :: k) (t :: k). HasBinaryProducts k => p s a -> q b t -> (s && b) ~> t
- type Lens (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (LensRes :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b
- type Lens' (s :: k) (a :: k) = Lens s s a a
- lens :: forall {k} (s :: k) (t :: k) (a :: k) (b :: k). (HasBinaryProducts k, Ob b) => (s ~> a) -> ((s && b) ~> t) -> Lens s t a b
- data Shop (a :: k) (b :: k) (s :: k) (t :: k) where
- withLens :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k) r. (HasBinaryProducts k, (Ob a, Ob b) => c (Shop a b)) => Optic c s t a b -> ((s ~> a) -> ((s && b) ~> t) -> r) -> r
- type LensVL s t a b = forall (f :: Type -> Type). Functor f => (a -> f b) -> s -> f t
- toLensVL :: Lens s t a b -> LensVL s t a b
- lensVL :: LensVL s t a b -> Lens s t a b
Documentation
class (AffineTravRes p q, GetterRes p q) => LensRes (p :: k +-> k) (q :: k +-> k) where Source Github #
Methods
putP :: forall (s :: k) (a :: k) (b :: k) (t :: k). HasBinaryProducts k => p s a -> q b t -> (s && b) ~> t Source Github #
Like affineSet, but with an honest constraint: lens witnesses only ever need binary
products, so lenses stay usable in categories without coproducts.
Instances
| CategoryOf k => LensRes (Id :: k -> k -> Type) (Id :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.Lens | |
| (HasBinaryProducts k, Ob s) => LensRes (Rep (Product s) :: k -> k -> Type) (Corep (Product s) :: k -> k -> Type) Source Github # | |
| (LensRes f g, LensRes f' g') => LensRes (f :.: f' :: i -> i -> Type) (g' :.: g :: i -> i -> Type) Source Github # | |
Defined in Proarrow.Optic.Lens | |
type Lens (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (LensRes :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b Source Github #
lens :: forall {k} (s :: k) (t :: k) (a :: k) (b :: k). (HasBinaryProducts k, Ob b) => (s ~> a) -> ((s && b) ~> t) -> Lens s t a b Source Github #
data Shop (a :: k) (b :: k) (s :: k) (t :: k) where Source Github #
The eliminating carrier for lenses: a lens's two legs, as a profunctor in s/t.
Constructors
| Shop :: forall {k} (a :: k) (b :: k) (s :: k) (t :: k). (Ob a, Ob b) => (s ~> a) -> ((s && b) ~> t) -> Shop a b s t |
Instances
| (HasBinaryProducts k, Ob a, Ob b, SubFlavor w (LensRes :: (k +-> k) -> (k +-> k) -> Constraint)) => Prostrong (w :: FLAVOR k k) (Shop a b :: k -> k -> Type) Source Github # | Any flavor whose optics have lens legs has strength for the |
Defined in Proarrow.Optic.Lens | |
| (HasBinaryProducts k, Ob a, Ob b) => Profunctor (Shop a b :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.Lens Methods dimap :: forall (c :: k) (a0 :: k) (b0 :: k) (d :: k). (c ~> a0) -> (b0 ~> d) -> Shop a b a0 b0 -> Shop a b c d Source Github # lmap :: forall (c :: k) (a0 :: k) (b0 :: k). (c ~> a0) -> Shop a b a0 b0 -> Shop a b c b0 Source Github # rmap :: forall (b0 :: k) (d :: k) (a0 :: k). (b0 ~> d) -> Shop a b a0 b0 -> Shop a b a0 d Source Github # (\\) :: forall (a0 :: k) (b0 :: k) r. ((Ob a0, Ob b0) => r) -> Shop a b a0 b0 -> r Source Github # | |
withLens :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k) r. (HasBinaryProducts k, (Ob a, Ob b) => c (Shop a b)) => Optic c s t a b -> ((s ~> a) -> ((s && b) ~> t) -> r) -> r Source Github #