proarrow
Safe HaskellNone
LanguageGHC2024

Proarrow.Optic.Getter

Description

The getter and its mirror the review: the one-leg optics s ~> a (GetterRes / 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 Rep/Corep Constant carriers.

Synopsis

Documentation

class AffineFoldRes p q => GetterRes (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) => GetterRes (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) => GetterRes (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 #

Comonoid m => GetterRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.MonoidalLens

Methods

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

(HasCoproducts k, Ob t) => GetterRes (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 #

(HasBinaryProducts k, Ob s) => GetterRes (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 #

(GetterRes f g, GetterRes f' g') => GetterRes (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 (GetterRes :: (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 => c (Rep (Constant a))) => Optic c s t a b -> s ~> a Source Github #

View through any optic that can act as a getter, in either encoding: a Prostrong-flavored optic needs SubFlavor w GetterRes (discharged by the bridge instance above), a profunctor-class-flavored optic needs its class to hold for the carrier.

(^.) :: forall (c :: (Type -> Type -> Type) -> Constraint) a s t b. c (Rep (Constant a)) => 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 (GetterRes :: (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 b => c (Corep (Constant b))) => Optic c s t a b -> b ~> t Source Github #

Review through any optic that can act as a review, in either encoding.

(#) :: forall (c :: (Type -> Type -> Type) -> Constraint) b s t a. c (Corep (Constant 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 #

Orphan instances

(CategoryOf j, CategoryOf k, Ob b, SubFlavor w (Flip (GetterRes :: (j +-> j) -> (k +-> k) -> Constraint))) => Prostrong (w :: FLAVOR j k) (Corep (Constant b) :: k -> j -> Type) Source Github #

The reviewing dual of the bridge above, over the carrier Corep (Constant b).

Instance details

Methods

proact :: forall (f :: k +-> k) (g :: j +-> j). (w f g, Profunctor f, Profunctor g) => ((f :.: Corep (Constant b)) :.: g) :~> Corep (Constant b) Source Github #

(CategoryOf j, CategoryOf k, Ob a, SubFlavor w (GetterRes :: (k +-> k) -> (j +-> j) -> Constraint)) => Prostrong (w :: FLAVOR j k) (Rep (Constant a) :: k -> j -> Type) Source Github #

Any flavor whose optics can view has strength for the viewing carrier Rep (Constant a). This is the bridge that lets the encoding-agnostic view below consume Prostrong-flavored optics; profunctor-class-flavored optics discharge the same c (Rep (Constant a)) constraint through the carrier's ordinary class instances instead.

Instance details

Methods

proact :: forall (f :: k +-> k) (g :: j +-> j). (w f g, Profunctor f, Profunctor g) => ((f :.: Rep (Constant a)) :.: g) :~> Rep (Constant a) Source Github #