proarrow
Safe HaskellNone
LanguageGHC2024

Proarrow.Optic.Iso

Description

The iso: the bottom of the subtyping lattice, usable as every other flavor. IsoFl is the conjunction of the five maximal flavors (LensFl, PrismFl, PowerGrateFl, MonLensFl and TracerFl). Build with iso, and eliminate to the two legs with withIso via the Yo carrier. That carrier also eliminates re-versed isos, a conversion the subtyping lattice itself cannot express. fromPIso/toPIso mediate with the profunctor-class-flavored PIso.

Synopsis

Documentation

class (LensFl p q, PrismFl p q, PowerGrateFl p q, MonLensFl p q, TracerFl p q) => IsoFl (p :: k +-> k) (q :: k +-> k) Source Github #

The iso flavor. Reversed isos still view/preview/fold (re iso is a getter, and more), through the GetterFl q p superclass of PrismFl.

Instances

Instances details
(LensFl p q, PrismFl p q, PowerGrateFl p q, MonLensFl p q, TracerFl p q) => IsoFl (p :: k +-> k) (q :: k +-> k) Source Github # 
Instance details

Defined in Proarrow.Optic.Iso

type Iso (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (IsoFl :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b Source Github #

The Prostrong-flavored iso; for the profunctor-class-flavored encoding see PIso.

type Iso' (s :: k) (a :: k) = Iso s s a a Source Github #

withIso :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k) r. (CategoryOf k, (Ob a, Ob b) => c (Yo a ('OP b))) => Optic c s t a b -> ((s ~> a) -> (b ~> t) -> r) -> r Source Github #

Eliminate any iso-flavored optic to its two legs, in either encoding, including the profunctor-class-flavored PIso and reversed (re) isos.

class CategoryOf k => DecidableIso k where Source Github #

Categories where it can be decided whether two objects are isomorphic, with an isomorphism when they are. The iso is an optic of any flavor c, so it can be used as a PIso, an Iso or anything those convert to, and taken apart with withIso.

Methods

isoOf :: forall (c :: (k +-> k) -> Constraint) (a :: k) (b :: k). (Ob a, Ob b) => Maybe (Optic c a a b b) Source Github #

Instances

Instances details
DecidableIso FINREL Source Github #

FR n and FR m are isomorphic when n and m are equal.

Instance details

Defined in Proarrow.Category.Instance.FinRel

Methods

isoOf :: forall (c :: (FINREL +-> FINREL) -> Constraint) (a :: FINREL) (b :: FINREL). (Ob a, Ob b) => Maybe (Optic c a a b b) Source Github #

DecidableIso DOT Source Github #

Two objects are isomorphic when they have the same wires.

Instance details

Defined in Proarrow.Tools.Diagrams.Dot

Methods

isoOf :: forall (c :: (DOT +-> DOT) -> Constraint) (a :: DOT) (b :: DOT). (Ob a, Ob b) => Maybe (Optic c a a b b) Source Github #

DecidableIso SVG Source Github #

Two objects are isomorphic when they have the same wires.

Instance details

Defined in Proarrow.Tools.Diagrams.Svg

Methods

isoOf :: forall (c :: (SVG +-> SVG) -> Constraint) (a :: SVG) (b :: SVG). (Ob a, Ob b) => Maybe (Optic c a a b b) Source Github #

Num a => DecidableIso (MatK a) Source Github #

M n and M m are isomorphic when n and m are equal.

Instance details

Defined in Proarrow.Category.Instance.Mat

Methods

isoOf :: forall (c :: (MatK a +-> MatK a) -> Constraint) (a0 :: MatK a) (b :: MatK a). (Ob a0, Ob b) => Maybe (Optic c a0 a0 b b) Source Github #

Scalar e => DecidableIso (TNET e) Source Github #

Two objects are isomorphic when they have the same dimensions.

Instance details

Defined in Proarrow.Category.Instance.TensorNetwork

Methods

isoOf :: forall (c :: (TNET e +-> TNET e) -> Constraint) (a :: TNET e) (b :: TNET e). (Ob a, Ob b) => Maybe (Optic c a a b b) Source Github #

isoFromEquality :: forall {k} (c :: (k +-> k) -> Constraint) (a :: k) (b :: k). (CategoryOf k, Ob a) => Maybe (a :~: b) -> Maybe (Optic c a a b b) Source Github #

The identity iso when two objects are equal.

fromPIso :: forall {k} (s :: k) (t :: k) (a :: k) (b :: k). CategoryOf k => PIso s t a b -> Iso s t a b Source Github #

The two iso encodings are equivalent: this direction instantiates the profunctor-class-flavored iso at the free IsoFl-strong profunctor ExOptic IsoFl a b, which needs nothing beyond its Profunctor instance.

toPIso :: forall {k} (s :: k) (t :: k) (a :: k) (b :: k). CategoryOf k => Iso s t a b -> PIso s t a b Source Github #

The other direction of the equivalence, by eliminating to legs and rebuilding.

Orphan instances

(CategoryOf k, forall (p :: k +-> k) (q :: k +-> k). w p q => Sub (IsoFl :: (k +-> k) -> (k +-> k) -> Constraint) p q) => Prostrong (w :: FLAVOR k k) (Yo a ('OP b) :: k -> k -> Type) Source Github #

Any flavor whose optics are isos has strength for the Yo profunctor.

Instance details

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (w f g, Profunctor f, Profunctor g) => ((f :.: Yo a ('OP b)) :.: g) :~> Yo a ('OP b) Source Github #