profunctor-optics-0.0.0.2: An optics library compatible with the typeclasses in 'profunctors'.

Safe HaskellNone
LanguageHaskell2010

Data.Profunctor.Optic.Traversal1

Contents

Synopsis

Traversal1

type Traversal1 s t a b = forall p. (Choice p, Representable p, Apply (Rep p)) => Optic p s t a b Source #

A Traversal1 processes 1 or more parts of the whole, with Apply interactions.

\( \mathsf{Traversal1}\;S\;A = \exists F : \mathsf{Traversable1}, S \equiv F\,A \)

type Traversal1' s a = Traversal1 s s a a Source #

type ATraversal1 f s t a b = Apply f => ARepn f s t a b Source #

type ATraversal1' f s a = ATraversal1 f s s a a Source #

traversal1 :: Traversable1 f => (s -> f a) -> (s -> f b -> t) -> Traversal1 s t a b Source #

Obtain a Traversal1 optic from a getter and setter.

\( \mathsf{Traversal1}\;S\;A = \exists F : \mathsf{Traversable1}, S \equiv F\,A \)

traversal1Vl :: (forall f. Apply f => (a -> f b) -> s -> f t) -> Traversal1 s t a b Source #

Obtain a profunctor Traversal1 from a Van Laarhoven Traversal1.

Caution: In order for the generated family to be well-defined, you must ensure that the traversal1 law holds for the input function:

  • fmap (abst f) . abst g ≡ getCompose . abst (Compose . fmap f . g)

See Property.

Cotraversal1 & Cxtraversal1

type Cotraversal1 s t a b = forall p. (Closed p, Corepresentable p, Apply (Corep p)) => Optic p s t a b Source #

type Cotraversal1' s a = Cotraversal1 s s a a Source #

type Cxtraversal1 k s t a b = forall p. (Closed p, Corepresentable p, Apply (Corep p)) => CoindexedOptic p k s t a b Source #

type Cxtraversal1' k s a = Cxtraversal1 k s s a a Source #

type ACotraversal1 f s t a b = Apply f => ACorepn f s t a b Source #

type ACotraversal1' f s a = ACotraversal1 f s s a a Source #

cotraversal1 :: Distributive g => (g b -> s -> g a) -> (g b -> t) -> Cotraversal1 s t a b Source #

Obtain a Cotraversal1 directly.

cotraversing1 :: Distributive g => (b -> s -> a) -> (b -> t) -> Cotraversal1 (g s) (g t) a b Source #

Obtain a Cotraversal1 by embedding a reversed lens getter and setter into a Distributive functor.

 withColens o cotraversingcotraversed . o

retraversing1 :: Distributive g => (((s -> a) -> b) -> t) -> Cotraversal1 (g s) (g t) a b Source #

Obtain a Cotraversal1 by embedding a grate continuation into a Distributive functor.

 withGrate o retraversingcotraversed . o

cotraversal1Vl :: (forall f. Apply f => (f a -> b) -> f s -> t) -> Cotraversal1 s t a b Source #

Obtain a profunctor Cotraversal1 from a Van Laarhoven Cotraversal1.

Caution: In order for the generated optic to be well-defined, you must ensure that the input satisfies the following properties:

  • abst f . fmap (abst g) ≡ abst (f . fmap g . getCompose) . Compose

See Property.

cxtraversal1Vl :: (forall f. Apply f => (k -> f a -> b) -> f s -> t) -> Cxtraversal1 k s t a b Source #

Lift an indexed VL cotraversal into a (co-)indexed profunctor cotraversal.

Caution: In order for the generated optic to be well-defined, you must ensure that the input satisfies the following properties:

  • kabst (const extract) ≡ extract
  • kabst (const f) . fmap (kabst $ const g) ≡ kabst ((const f) . fmap (const g) . getCompose) . Compose

See Property.

nocx1 :: Monoid k => Cotraversal1 s t a b -> Cxtraversal1 k s t a b Source #

Lift a VL cotraversal into an (co-)indexed profunctor cotraversal that ignores its input.

Useful as the first optic in a chain when no indexed equivalent is at hand.

Optics

traversed1 :: Traversable1 t => Traversal1 (t a) (t b) a b Source #

Obtain a Traversal1 from a Traversable1 functor.

cotraversed1 :: Distributive f => Cotraversal1 (f a) (f b) a b Source #

TODO: Document

both1 :: Traversal1 (a, a) (b, b) a b Source #

TODO: Document

>>> withTraversal1 both1 (pure . NE.length) ('h' :| "ello", 'w' :| "orld")
(5,5)

bitraversed1 :: Bitraversable1 r => Traversal1 (r a a) (r b b) a b Source #

Traverse both parts of a Bitraversable1 container with matching types.

>>> withTraversal1 bitraversed1 (pure . NE.length) ('h' :| "ello", 'w' :| "orld")
(5,5)

repeated :: Traversal1' a a Source #

Obtain a Traversal1' by repeating the input forever.

repeatlists repeated
>>> take 5 $ 5 ^.. repeated
[5,5,5,5,5]
repeated :: Fold1 a a

iterated :: (a -> a) -> Traversal1' a a Source #

x ^. iterated f returns an infinite Traversal1' of repeated applications of f to x.

lists (iterated f) a ≡ iterate f a
>>> take 3 $ (1 :: Int) ^.. iterated (+1)
[1,2,3]
iterated :: (a -> a) -> Fold1 a a

cycled :: Apply f => ATraversal1' f s a -> ATraversal1' f s a Source #

Transform a Traversal1' into a Traversal1' that loops repn its elements repeatedly.

>>> take 7 $ (1 :| [2,3]) ^.. cycled traversed1
[1,2,3,1,2,3,1]
cycled :: Fold1 s a -> Fold1 s a

Primitive operators

withTraversal1 :: Apply f => ATraversal1 f s t a b -> (a -> f b) -> s -> f t Source #

The traversal laws can be stated in terms or withTraversal1:

Identity:

withTraversal1 t (Identity . f) ≡  Identity (fmap f)

Composition:

Compose . fmap (withTraversal1 t f) . withTraversal1 t g ≡ withTraversal1 t (Compose . fmap f . g)
withTraversal1 :: Functor f => Lens s t a b -> (a -> f b) -> s -> f t
withTraversal1 :: Apply f => Traversal1 s t a b -> (a -> f b) -> s -> f t

withCotraversal1 :: Functor f => Optic (Costar f) s t a b -> (f a -> b) -> f s -> t Source #

TODO: Document

withCotraversal1 $ grate (flip cotraverse id) ≡ cotraverse

Operators

sequences1 :: Apply f => ATraversal1 f s t (f a) a -> s -> f t Source #

TODO: Document

distributes1 :: Apply f => ACotraversal1 f s t a (f a) -> f s -> t Source #

TODO: Document

Carriers

newtype Star (f :: Type -> Type) d c #

Lift a Functor into a Profunctor (forwards).

Constructors

Star 

Fields

Instances
Functor f => Representable (Star f) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Rep (Star f) :: Type -> Type #

Methods

tabulate :: (d -> Rep (Star f) c) -> Star f d c #

Applicative f => Choice (Star f) 
Instance details

Defined in Data.Profunctor.Choice

Methods

left' :: Star f a b -> Star f (Either a c) (Either b c) #

right' :: Star f a b -> Star f (Either c a) (Either c b) #

Traversable f => Cochoice (Star f) 
Instance details

Defined in Data.Profunctor.Choice

Methods

unleft :: Star f (Either a d) (Either b d) -> Star f a b #

unright :: Star f (Either d a) (Either d b) -> Star f a b #

Distributive f => Closed (Star f) 
Instance details

Defined in Data.Profunctor.Closed

Methods

closed :: Star f a b -> Star f (x -> a) (x -> b) #

Functor m => Strong (Star m) 
Instance details

Defined in Data.Profunctor.Strong

Methods

first' :: Star m a b -> Star m (a, c) (b, c) #

second' :: Star m a b -> Star m (c, a) (c, b) #

Functor f => Profunctor (Star f) 
Instance details

Defined in Data.Profunctor.Types

Methods

dimap :: (a -> b) -> (c -> d) -> Star f b c -> Star f a d #

lmap :: (a -> b) -> Star f b c -> Star f a c #

rmap :: (b -> c) -> Star f a b -> Star f a c #

(#.) :: Coercible c b => q b c -> Star f a b -> Star f a c #

(.#) :: Coercible b a => Star f b c -> q a b -> Star f a c #

Functor f => Sieve (Star f) f 
Instance details

Defined in Data.Profunctor.Sieve

Methods

sieve :: Star f a b -> a -> f b #

Monad f => Category (Star f :: Type -> Type -> Type) 
Instance details

Defined in Data.Profunctor.Types

Methods

id :: Star f a a #

(.) :: Star f b c -> Star f a b -> Star f a c #

Monad f => Monad (Star f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

(>>=) :: Star f a a0 -> (a0 -> Star f a b) -> Star f a b #

(>>) :: Star f a a0 -> Star f a b -> Star f a b #

return :: a0 -> Star f a a0 #

fail :: String -> Star f a a0 #

Functor f => Functor (Star f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

fmap :: (a0 -> b) -> Star f a a0 -> Star f a b #

(<$) :: a0 -> Star f a b -> Star f a a0 #

Applicative f => Applicative (Star f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

pure :: a0 -> Star f a a0 #

(<*>) :: Star f a (a0 -> b) -> Star f a a0 -> Star f a b #

liftA2 :: (a0 -> b -> c) -> Star f a a0 -> Star f a b -> Star f a c #

(*>) :: Star f a a0 -> Star f a b -> Star f a b #

(<*) :: Star f a a0 -> Star f a b -> Star f a a0 #

Contravariant f => Contravariant (Star f a) Source # 
Instance details

Defined in Data.Profunctor.Optic.Type

Methods

contramap :: (a0 -> b) -> Star f a b -> Star f a a0 #

(>$) :: b -> Star f a b -> Star f a a0 #

Alternative f => Alternative (Star f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

empty :: Star f a a0 #

(<|>) :: Star f a a0 -> Star f a a0 -> Star f a a0 #

some :: Star f a a0 -> Star f a [a0] #

many :: Star f a a0 -> Star f a [a0] #

MonadPlus f => MonadPlus (Star f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

mzero :: Star f a a0 #

mplus :: Star f a a0 -> Star f a a0 -> Star f a a0 #

Distributive f => Distributive (Star f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

distribute :: Functor f0 => f0 (Star f a a0) -> Star f a (f0 a0) #

collect :: Functor f0 => (a0 -> Star f a b) -> f0 a0 -> Star f a (f0 b) #

distributeM :: Monad m => m (Star f a a0) -> Star f a (m a0) #

collectM :: Monad m => (a0 -> Star f a b) -> m a0 -> Star f a (m b) #

Apply f => Apply (Star f a) Source # 
Instance details

Defined in Data.Profunctor.Optic.Type

Methods

(<.>) :: Star f a (a0 -> b) -> Star f a a0 -> Star f a b #

(.>) :: Star f a a0 -> Star f a b -> Star f a b #

(<.) :: Star f a a0 -> Star f a b -> Star f a a0 #

liftF2 :: (a0 -> b -> c) -> Star f a a0 -> Star f a b -> Star f a c #

type Rep (Star f) 
Instance details

Defined in Data.Profunctor.Rep

type Rep (Star f) = f

newtype Costar (f :: Type -> Type) d c #

Lift a Functor into a Profunctor (backwards).

Constructors

Costar 

Fields

Instances
Contravariant f => Bifunctor (Costar f) Source # 
Instance details

Defined in Data.Profunctor.Optic.Type

Methods

bimap :: (a -> b) -> (c -> d) -> Costar f a c -> Costar f b d #

first :: (a -> b) -> Costar f a c -> Costar f b c #

second :: (b -> c) -> Costar f a b -> Costar f a c #

Functor f => Corepresentable (Costar f) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Corep (Costar f) :: Type -> Type #

Methods

cotabulate :: (Corep (Costar f) d -> c) -> Costar f d c #

Traversable w => Choice (Costar w) 
Instance details

Defined in Data.Profunctor.Choice

Methods

left' :: Costar w a b -> Costar w (Either a c) (Either b c) #

right' :: Costar w a b -> Costar w (Either c a) (Either c b) #

Applicative f => Cochoice (Costar f) 
Instance details

Defined in Data.Profunctor.Choice

Methods

unleft :: Costar f (Either a d) (Either b d) -> Costar f a b #

unright :: Costar f (Either d a) (Either d b) -> Costar f a b #

Functor f => Closed (Costar f) 
Instance details

Defined in Data.Profunctor.Closed

Methods

closed :: Costar f a b -> Costar f (x -> a) (x -> b) #

Comonad f => Strong (Costar f) Source # 
Instance details

Defined in Data.Profunctor.Optic.Type

Methods

first' :: Costar f a b -> Costar f (a, c) (b, c) #

second' :: Costar f a b -> Costar f (c, a) (c, b) #

Functor f => Costrong (Costar f) 
Instance details

Defined in Data.Profunctor.Strong

Methods

unfirst :: Costar f (a, d) (b, d) -> Costar f a b #

unsecond :: Costar f (d, a) (d, b) -> Costar f a b #

Functor f => Profunctor (Costar f) 
Instance details

Defined in Data.Profunctor.Types

Methods

dimap :: (a -> b) -> (c -> d) -> Costar f b c -> Costar f a d #

lmap :: (a -> b) -> Costar f b c -> Costar f a c #

rmap :: (b -> c) -> Costar f a b -> Costar f a c #

(#.) :: Coercible c b => q b c -> Costar f a b -> Costar f a c #

(.#) :: Coercible b a => Costar f b c -> q a b -> Costar f a c #

Functor f => Cosieve (Costar f) f 
Instance details

Defined in Data.Profunctor.Sieve

Methods

cosieve :: Costar f a b -> f a -> b #

Monad (Costar f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

(>>=) :: Costar f a a0 -> (a0 -> Costar f a b) -> Costar f a b #

(>>) :: Costar f a a0 -> Costar f a b -> Costar f a b #

return :: a0 -> Costar f a a0 #

fail :: String -> Costar f a a0 #

Functor (Costar f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

fmap :: (a0 -> b) -> Costar f a a0 -> Costar f a b #

(<$) :: a0 -> Costar f a b -> Costar f a a0 #

Applicative (Costar f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

pure :: a0 -> Costar f a a0 #

(<*>) :: Costar f a (a0 -> b) -> Costar f a a0 -> Costar f a b #

liftA2 :: (a0 -> b -> c) -> Costar f a a0 -> Costar f a b -> Costar f a c #

(*>) :: Costar f a a0 -> Costar f a b -> Costar f a b #

(<*) :: Costar f a a0 -> Costar f a b -> Costar f a a0 #

Distributive (Costar f d) 
Instance details

Defined in Data.Profunctor.Types

Methods

distribute :: Functor f0 => f0 (Costar f d a) -> Costar f d (f0 a) #

collect :: Functor f0 => (a -> Costar f d b) -> f0 a -> Costar f d (f0 b) #

distributeM :: Monad m => m (Costar f d a) -> Costar f d (m a) #

collectM :: Monad m => (a -> Costar f d b) -> m a -> Costar f d (m b) #

type Corep (Costar f) 
Instance details

Defined in Data.Profunctor.Rep

type Corep (Costar f) = f

Classes

class (Sieve p (Rep p), Strong p) => Representable (p :: Type -> Type -> Type) where #

A Profunctor p is Representable if there exists a Functor f such that p d c is isomorphic to d -> f c.

Associated Types

type Rep (p :: Type -> Type -> Type) :: Type -> Type #

Methods

tabulate :: (d -> Rep p c) -> p d c #

Instances
(Monad m, Functor m) => Representable (Kleisli m) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Rep (Kleisli m) :: Type -> Type #

Methods

tabulate :: (d -> Rep (Kleisli m) c) -> Kleisli m d c #

Functor f => Representable (Star f) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Rep (Star f) :: Type -> Type #

Methods

tabulate :: (d -> Rep (Star f) c) -> Star f d c #

Representable (Forget r) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Rep (Forget r) :: Type -> Type #

Methods

tabulate :: (d -> Rep (Forget r) c) -> Forget r d c #

Representable (Fold0Rep r) Source # 
Instance details

Defined in Data.Profunctor.Optic.Fold0

Associated Types

type Rep (Fold0Rep r) :: Type -> Type #

Methods

tabulate :: (d -> Rep (Fold0Rep r) c) -> Fold0Rep r d c #

Representable ((->) :: Type -> Type -> Type) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Rep (->) :: Type -> Type #

Methods

tabulate :: (d -> Rep (->) c) -> d -> c #

Representable (LensRep a b) Source # 
Instance details

Defined in Data.Profunctor.Optic.Lens

Associated Types

type Rep (LensRep a b) :: Type -> Type #

Methods

tabulate :: (d -> Rep (LensRep a b) c) -> LensRep a b d c #

Representable (Traversal0Rep a b) Source # 
Instance details

Defined in Data.Profunctor.Optic.Traversal0

Associated Types

type Rep (Traversal0Rep a b) :: Type -> Type #

Methods

tabulate :: (d -> Rep (Traversal0Rep a b) c) -> Traversal0Rep a b d c #

class (Cosieve p (Corep p), Costrong p) => Corepresentable (p :: Type -> Type -> Type) where #

A Profunctor p is Corepresentable if there exists a Functor f such that p d c is isomorphic to f d -> c.

Associated Types

type Corep (p :: Type -> Type -> Type) :: Type -> Type #

Methods

cotabulate :: (Corep p d -> c) -> p d c #

Instances
Functor f => Corepresentable (Costar f) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Corep (Costar f) :: Type -> Type #

Methods

cotabulate :: (Corep (Costar f) d -> c) -> Costar f d c #

Corepresentable (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Corep Tagged :: Type -> Type #

Methods

cotabulate :: (Corep Tagged d -> c) -> Tagged d c #

Corepresentable ((->) :: Type -> Type -> Type) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Corep (->) :: Type -> Type #

Methods

cotabulate :: (Corep (->) d -> c) -> d -> c #

Functor w => Corepresentable (Cokleisli w) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Corep (Cokleisli w) :: Type -> Type #

Methods

cotabulate :: (Corep (Cokleisli w) d -> c) -> Cokleisli w d c #

Corepresentable (GrateRep a b) Source # 
Instance details

Defined in Data.Profunctor.Optic.Grate

Associated Types

type Corep (GrateRep a b) :: Type -> Type #

Methods

cotabulate :: (Corep (GrateRep a b) d -> c) -> GrateRep a b d c #