proarrow
Safe HaskellNone
LanguageGHC2024

Proarrow.Optic.Getter

Description

The getter and its mirror the review: the one-leg optics s ~> a (GetterFl / getP) and b ~> t (its Flip). A getter is an affine fold that always succeeds; a review is what remains of a prism's build leg. Build them from a single morphism with to / unto, and eliminate with view / (^.) and review / (#), via the generic ExOptic carrier.

Synopsis

Documentation

class AffineFoldFl p q => GetterFl (p :: k +-> k) (q :: j +-> j) where Source Github #

Methods

getP :: forall (s :: k) (a :: k). p s a -> s ~> a Source Github #

Instances

Instances details
(CategoryOf k, CategoryOf j) => GetterFl (Id :: k -> k -> Type) (Id :: j -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Getter

Methods

getP :: forall (s :: k) (a :: k). Id s a -> s ~> a Source Github #

(CategoryOf k, CategoryOf j) => GetterFl (Id :: k -> k -> Type) (TerminalProfunctor :: j -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Getter

Methods

getP :: forall (s :: k) (a :: k). Id s a -> s ~> a Source Github #

(HasCoproducts k, Ob t) => GetterFl (Corep (Coproduct t) :: k -> k -> Type) (Rep (Coproduct t) :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Getter

Methods

getP :: forall (s :: k) (a :: k). Corep (Coproduct t) s a -> s ~> a Source Github #

Comonoid m => GetterFl (Rep (ActionAt (Tensor :: k -> (k, k) -> Type) m) :: k -> k -> Type) (Corep (ActionAt (Tensor :: k -> (k, k) -> Type) m) :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.MonoidalLens

Methods

getP :: forall (s :: k) (a :: k). Rep (ActionAt (Tensor :: k -> (k, k) -> Type) m) s a -> s ~> a Source Github #

(HasBinaryProducts k, Ob s) => GetterFl (Rep (Product s) :: k -> k -> Type) (Corep (Product s) :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Getter

Methods

getP :: forall (s0 :: k) (a :: k). Rep (Product s) s0 a -> s0 ~> a Source Github #

(GetterFl f g, GetterFl f' g') => GetterFl (f :.: f' :: k -> k -> Type) (g' :.: g :: j -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Getter

Methods

getP :: forall (s :: k) (a :: k). (f :.: f') s a -> s ~> a Source Github #

type Getter (s :: k) (t :: j) (a :: k) (b :: j) = Optic (Prostrong (GetterFl :: (k +-> k) -> (j +-> j) -> Constraint)) s t a b Source Github #

view :: forall {j} {k} (c :: (k -> j -> Type) -> Constraint) (s :: k) (t :: j) (a :: k) (b :: j). (CategoryOf j, CategoryOf k, (Ob a, Ob b) => c (ExOptic (GetterFl :: (k +-> k) -> (j +-> j) -> Constraint) a b)) => Optic c s t a b -> s ~> a Source Github #

View through any optic that can act as a getter, in either encoding: run it at its witness pair (ExOptic GetterFl, via withLegs) and read the get leg off with getP.

(^.) :: forall (c :: (Type -> Type -> Type) -> Constraint) a b s t. c (ExOptic (GetterFl :: (Type +-> Type) -> (Type +-> Type) -> Constraint) a b) => s -> Optic c s t a b -> a infixl 8 Source Github #

View the focus of a concrete, Type-level optic.

to :: forall {k} {j} (s :: k) (t :: j) (a :: k) (b :: j). (CategoryOf k, CategoryOf j, Ob b, Ob t) => (s ~> a) -> Getter s t a b Source Github #

type Review (s :: k) (t :: j) (a :: k) (b :: j) = Optic (Prostrong (Flip (GetterFl :: (j +-> j) -> (k +-> k) -> Constraint))) s t a b Source Github #

review :: forall {j} {k} (c :: (k -> j -> Type) -> Constraint) (s :: k) (t :: j) (a :: k) (b :: j). (CategoryOf j, CategoryOf k, (Ob a, Ob b) => c (ExOptic (Flip (GetterFl :: (j +-> j) -> (k +-> k) -> Constraint)) a b)) => Optic c s t a b -> b ~> t Source Github #

Review through any optic that can act as a review, in either encoding: getP on the flipped witness pair.

(#) :: forall (c :: (Type -> Type -> Type) -> Constraint) a b s t. c (ExOptic (Flip (GetterFl :: (Type +-> Type) -> (Type +-> Type) -> Constraint)) a b) => Optic c s t a b -> b -> t infixr 8 Source Github #

Review through a concrete, Type-level optic.

unto :: forall {k} {j} (s :: k) (t :: j) (a :: k) (b :: j). (CategoryOf k, CategoryOf j, Ob s, Ob a) => (b ~> t) -> Review s t a b Source Github #