| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Profunctor.Optic.Traversal1
Synopsis
- type Traversal1 s t a b = forall p. (Choice p, Representable p, Apply (Rep p)) => Optic p s t a b
- type Traversal1' s a = Traversal1 s s a a
- type ATraversal1 f s t a b = Apply f => ARepn f s t a b
- type ATraversal1' f s a = ATraversal1 f s s a a
- traversal1 :: Traversable1 f => (s -> f a) -> (s -> f b -> t) -> Traversal1 s t a b
- traversal1Vl :: (forall f. Apply f => (a -> f b) -> s -> f t) -> Traversal1 s t a b
- type Cotraversal1 s t a b = forall p. (Closed p, Corepresentable p, Apply (Corep p)) => Optic p s t a b
- type Cotraversal1' s a = Cotraversal1 s s a a
- type Cxtraversal1 k s t a b = forall p. (Closed p, Corepresentable p, Apply (Corep p)) => CoindexedOptic p k s t a b
- type Cxtraversal1' k s a = Cxtraversal1 k s s a a
- type ACotraversal1 f s t a b = Apply f => ACorepn f s t a b
- type ACotraversal1' f s a = ACotraversal1 f s s a a
- cotraversal1 :: Distributive g => (g b -> s -> g a) -> (g b -> t) -> Cotraversal1 s t a b
- cotraversing1 :: Distributive g => (b -> s -> a) -> (b -> t) -> Cotraversal1 (g s) (g t) a b
- retraversing1 :: Distributive g => (((s -> a) -> b) -> t) -> Cotraversal1 (g s) (g t) a b
- cotraversal1Vl :: (forall f. Apply f => (f a -> b) -> f s -> t) -> Cotraversal1 s t a b
- cxtraversal1Vl :: (forall f. Apply f => (k -> f a -> b) -> f s -> t) -> Cxtraversal1 k s t a b
- nocx1 :: Monoid k => Cotraversal1 s t a b -> Cxtraversal1 k s t a b
- traversed1 :: Traversable1 t => Traversal1 (t a) (t b) a b
- cotraversed1 :: Distributive f => Cotraversal1 (f a) (f b) a b
- both1 :: Traversal1 (a, a) (b, b) a b
- bitraversed1 :: Bitraversable1 r => Traversal1 (r a a) (r b b) a b
- repeated :: Traversal1' a a
- iterated :: (a -> a) -> Traversal1' a a
- cycled :: Apply f => ATraversal1' f s a -> ATraversal1' f s a
- withTraversal1 :: Apply f => ATraversal1 f 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
- sequences1 :: Apply f => ATraversal1 f s t (f a) a -> s -> f t
- distributes1 :: Apply f => ACotraversal1 f s t a (f a) -> f s -> t
- newtype Star (f :: Type -> Type) d c = Star {
- runStar :: d -> f c
- newtype Costar (f :: Type -> Type) d c = Costar {
- runCostar :: f d -> c
- class (Sieve p (Rep p), Strong p) => Representable (p :: Type -> Type -> Type) where
- class (Cosieve p (Corep p), Costrong p) => Corepresentable (p :: Type -> Type -> Type) where
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.
withColensocotraversing≡cotraversed. 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.
withGrateoretraversing≡cotraversed. 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.
repeat≡listsrepeated
>>>take 5 $ 5 ^.. repeated[5,5,5,5,5]
repeated :: Fold1 a a
iterated :: (a -> a) -> Traversal1' a a Source #
x returns an infinite ^. iterated fTraversal1' of repeated applications of f to x.
lists(iteratedf) a ≡iteratef 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 ::Fold1s a ->Fold1s 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(flipcotraverseid) ≡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).
Instances
| Functor f => Representable (Star f) | |
| Applicative f => Choice (Star f) | |
| Traversable f => Cochoice (Star f) | |
| Distributive f => Closed (Star f) | |
Defined in Data.Profunctor.Closed | |
| Functor m => Strong (Star m) | |
| Functor f => Profunctor (Star f) | |
Defined in Data.Profunctor.Types | |
| Functor f => Sieve (Star f) f | |
Defined in Data.Profunctor.Sieve | |
| Monad f => Category (Star f :: Type -> Type -> Type) | |
| Monad f => Monad (Star f a) | |
| Functor f => Functor (Star f a) | |
| Applicative f => Applicative (Star f a) | |
| Contravariant f => Contravariant (Star f a) Source # | |
| Alternative f => Alternative (Star f a) | |
| MonadPlus f => MonadPlus (Star f a) | |
| Distributive f => Distributive (Star f a) | |
Defined in Data.Profunctor.Types | |
| Apply f => Apply (Star f a) Source # | |
| type Rep (Star f) | |
Defined in Data.Profunctor.Rep | |
newtype Costar (f :: Type -> Type) d c #
Lift a Functor into a Profunctor (backwards).
Instances
| Contravariant f => Bifunctor (Costar f) Source # | |
| Functor f => Corepresentable (Costar f) | |
| Traversable w => Choice (Costar w) | |
| Applicative f => Cochoice (Costar f) | |
| Functor f => Closed (Costar f) | |
Defined in Data.Profunctor.Closed | |
| Comonad f => Strong (Costar f) Source # | |
| Functor f => Costrong (Costar f) | |
| Functor f => Profunctor (Costar f) | |
Defined in Data.Profunctor.Types | |
| Functor f => Cosieve (Costar f) f | |
Defined in Data.Profunctor.Sieve | |
| Monad (Costar f a) | |
| Functor (Costar f a) | |
| Applicative (Costar f a) | |
Defined in Data.Profunctor.Types | |
| Distributive (Costar f d) | |
Defined in Data.Profunctor.Types | |
| type Corep (Costar f) | |
Defined in Data.Profunctor.Rep | |
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.
Instances
| (Monad m, Functor m) => Representable (Kleisli m) | |
| Functor f => Representable (Star f) | |
| Representable (Forget r) | |
| Representable (Fold0Rep r) Source # | |
| Representable ((->) :: Type -> Type -> Type) | |
| Representable (LensRep a b) Source # | |
| Representable (Traversal0Rep a b) Source # | |
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.
Methods
cotabulate :: (Corep p d -> c) -> p d c #
Laws:
cotabulate.cosieve≡idcosieve.cotabulate≡id
Instances
| Functor f => Corepresentable (Costar f) | |
| Corepresentable (Tagged :: Type -> Type -> Type) | |
| Corepresentable ((->) :: Type -> Type -> Type) | |
Defined in Data.Profunctor.Rep Methods cotabulate :: (Corep (->) d -> c) -> d -> c # | |
| Functor w => Corepresentable (Cokleisli w) | |
| Corepresentable (GrateRep a b) Source # | |