optics-core-0.1

Safe HaskellNone
LanguageHaskell2010

Optics.Iso

Contents

Synopsis

Documentation

data An_Iso :: OpticKind #

Tag for an iso.

Instances
ReversibleOptic An_Iso # 
Instance details

Defined in Optics.Internal.Re

Associated Types

type ReversedOptic An_Iso :: OpticKind #

Methods

re :: Optic An_Iso [] s t a b -> Optic (ReversedOptic An_Iso) [] b a t s #

Is An_Iso A_Review # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: proxy An_Iso A_Review p -> (Constraints An_Iso p -> r) -> Constraints A_Review p -> r

Is An_Iso A_LensyReview # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: proxy An_Iso A_LensyReview p -> (Constraints An_Iso p -> r) -> Constraints A_LensyReview p -> r

Is An_Iso A_Fold # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: proxy An_Iso A_Fold p -> (Constraints An_Iso p -> r) -> Constraints A_Fold p -> r

Is An_Iso An_AffineFold # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: proxy An_Iso An_AffineFold p -> (Constraints An_Iso p -> r) -> Constraints An_AffineFold p -> r

Is An_Iso A_Getter # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: proxy An_Iso A_Getter p -> (Constraints An_Iso p -> r) -> Constraints A_Getter p -> r

Is An_Iso A_PrismaticGetter # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: proxy An_Iso A_PrismaticGetter p -> (Constraints An_Iso p -> r) -> Constraints A_PrismaticGetter p -> r

Is An_Iso A_Setter # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: proxy An_Iso A_Setter p -> (Constraints An_Iso p -> r) -> Constraints A_Setter p -> r

Is An_Iso A_Traversal # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: proxy An_Iso A_Traversal p -> (Constraints An_Iso p -> r) -> Constraints A_Traversal p -> r

Is An_Iso An_AffineTraversal # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: proxy An_Iso An_AffineTraversal p -> (Constraints An_Iso p -> r) -> Constraints An_AffineTraversal p -> r

Is An_Iso A_Prism # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: proxy An_Iso A_Prism p -> (Constraints An_Iso p -> r) -> Constraints A_Prism p -> r

Is An_Iso A_Lens # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: proxy An_Iso A_Lens p -> (Constraints An_Iso p -> r) -> Constraints A_Lens p -> r

Is An_Equality An_Iso # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: proxy An_Equality An_Iso p -> (Constraints An_Equality p -> r) -> Constraints An_Iso p -> r

Arrow arr => ArrowOptic An_Iso arr # 
Instance details

Defined in Optics.Arrow

Methods

overA :: Optic An_Iso [] s t a b -> arr a b -> arr s t #

ViewableOptic An_Iso r # 
Instance details

Defined in Optics.Internal.View

Associated Types

type ViewResult An_Iso r :: * #

Methods

view :: Optic' An_Iso is s r -> s -> ViewResult An_Iso r #

PermeableOptic An_Iso r # 
Instance details

Defined in Optics.Internal.Passthrough

Methods

passthrough :: Optic An_Iso is s t a b -> (a -> (r, b)) -> s -> (ViewResult An_Iso r, t) #

type ReversedOptic An_Iso # 
Instance details

Defined in Optics.Internal.Re

type ViewResult An_Iso r # 
Instance details

Defined in Optics.Internal.View

type ViewResult An_Iso r = r

type Iso s t a b = Optic An_Iso '[] s t a b #

Type synonym for a type-modifying iso.

type Iso' s a = Optic' An_Iso '[] s a #

Type synonym for a type-preserving iso.

toIso :: Is k An_Iso => Optic k is s t a b -> Optic An_Iso is s t a b #

Explicitly cast an optic to an iso.

iso :: (s -> a) -> (b -> t) -> Iso s t a b #

Build an iso from a pair of inverse functions.

withIso :: Is k An_Iso => Optic k is s t a b -> ((s -> a) -> (b -> t) -> r) -> r #

Extract the two components of an isomorphism.

Isomorphisms

mapping :: (Is k An_Iso, Functor f, Functor g) => Optic k '[] s t a b -> Iso (f s) (g t) (f a) (g b) #

This can be used to lift any Iso into an arbitrary Functor.

curried :: Iso ((a, b) -> c) ((d, e) -> f) (a -> b -> c) (d -> e -> f) #

The canonical isomorphism for currying and uncurrying a function.

curried = iso curry uncurry
>>> view curried fst 3 4
3

uncurried :: Iso (a -> b -> c) (d -> e -> f) ((a, b) -> c) ((d, e) -> f) #

The canonical isomorphism for uncurrying and currying a function.

uncurried = iso uncurry curry
uncurried = from curried
>>> (view uncurried (+)) (1,2)
3

flipped :: Iso (a -> b -> c) (a' -> b' -> c') (b -> a -> c) (b' -> a' -> c') #

The isomorphism for flipping a function.

>>> (view flipped (,)) 1 2
(2,1)

class Bifunctor p => Swapped p where #

This class provides for symmetric bifunctors.

Minimal complete definition

swapped

Methods

swapped :: Iso (p a b) (p c d) (p b a) (p d c) #

swapped . swappedid
first f . swapped = swapped . second f
second g . swapped = swapped . first g
bimap f g . swapped = swapped . bimap g f
>>> view swapped (1,2)
(2,1)
Instances
Swapped Either # 
Instance details

Defined in Optics.Iso

Methods

swapped :: Iso (Either a b) (Either c d) (Either b a) (Either d c) #

Swapped (,) # 
Instance details

Defined in Optics.Iso

Methods

swapped :: Iso (a, b) (c, d) (b, a) (d, c) #