profunctors-5.6.2: Profunctors

Safe Haskell | Safe
Language | Haskell2010

Data.Profunctor.Traversing

Contents

- Profunctor in terms of Traversing
- Strong in terms of Traversing
- Choice in terms of Traversing

Synopsis

- class (Choice p, Strong p) => Traversing (p :: Type -> Type -> Type) where
  - traverse' :: Traversable f => p a b -> p (f a) (f b)
  - wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> p a b -> p s t
- newtype CofreeTraversing (p :: Type -> Type -> Type) a b = CofreeTraversing {
  - runCofreeTraversing :: forall (f :: Type -> Type). Traversable f => p (f a) (f b)
  }
- data FreeTraversing (p :: Type -> Type -> Type) a b where
  - FreeTraversing :: forall (f :: Type -> Type) y b (p :: Type -> Type -> Type) x a. Traversable f => (f y -> b) -> p x y -> (a -> f x) -> FreeTraversing p a b
- dimapWandering :: Traversing p => (a' -> a) -> (b -> b') -> p a b -> p a' b'
- lmapWandering :: Traversing p => (a -> b) -> p b c -> p a c
- rmapWandering :: Traversing p => (b -> c) -> p a b -> p a c
- firstTraversing :: Traversing p => p a b -> p (a, c) (b, c)
- secondTraversing :: Traversing p => p a b -> p (c, a) (c, b)
- leftTraversing :: Traversing p => p a b -> p (Either a c) (Either b c)
- rightTraversing :: Traversing p => p a b -> p (Either c a) (Either c b)

# Documentation

class (Choice p, Strong p) => Traversing (p :: Type -> Type -> Type) where #

Note: Definitions in terms of `wander` are much more efficient!

Minimal complete definition

wander | traverse'

Methods

traverse' :: Traversable f => p a b -> p (f a) (f b) #

Laws:

    traverse' ≡ wander traverse
    traverse' . rmap f ≡ rmap (fmap f) . traverse'
    traverse' . traverse' ≡ dimap Compose getCompose . traverse'
    dimap Identity runIdentity . traverse' ≡ id

wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> p a b -> p s t #

This combinator is mutually defined in terms of `traverse'`

#### Instances

Instances details

Monad m => Traversing (Kleisli m) # |
Instance details Defined in Data.Profunctor.Traversing Methods traverse' :: Traversable f => Kleisli m a b -> Kleisli m (f a) (f b) # wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> Kleisli m a b -> Kleisli m s t #
Profunctor p => Traversing (CofreeMapping p) # |
Instance details Defined in Data.Profunctor.Mapping Methods traverse' :: Traversable f => CofreeMapping p a b -> CofreeMapping p (f a) (f b) # wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> CofreeMapping p a b -> CofreeMapping p s t #
Traversing (FreeMapping p) # |
Instance details Defined in Data.Profunctor.Mapping Methods traverse' :: Traversable f => FreeMapping p a b -> FreeMapping p (f a) (f b) # wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> FreeMapping p a b -> FreeMapping p s t #
Profunctor p => Traversing (CofreeTraversing p) # |
Instance details Defined in Data.Profunctor.Traversing Methods traverse' :: Traversable f => CofreeTraversing p a b -> CofreeTraversing p (f a) (f b) # wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> CofreeTraversing p a b -> CofreeTraversing p s t #
Traversing (FreeTraversing p) # |
Instance details Defined in Data.Profunctor.Traversing Methods traverse' :: Traversable f => FreeTraversing p a b -> FreeTraversing p (f a) (f b) # wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> FreeTraversing p a b -> FreeTraversing p s t #
Traversing p => Traversing (Coyoneda p) # |
Instance details Defined in Data.Profunctor.Yoneda Methods traverse' :: Traversable f => Coyoneda p a b -> Coyoneda p (f a) (f b) # wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> Coyoneda p a b -> Coyoneda p s t #
Traversing p => Traversing (Yoneda p) # |
Instance details Defined in Data.Profunctor.Yoneda Methods traverse' :: Traversable f => Yoneda p a b -> Yoneda p (f a) (f b) # wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> Yoneda p a b -> Yoneda p s t #
Monoid m => Traversing (Forget m :: Type -> Type -> Type) # |
Instance details Defined in Data.Profunctor.Traversing Methods traverse' :: Traversable f => Forget m a b -> Forget m (f a) (f b) # wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> Forget m a b -> Forget m s t #
Applicative m => Traversing (Star m) # |
Instance details Defined in Data.Profunctor.Traversing Methods traverse' :: Traversable f => Star m a b -> Star m (f a) (f b) # wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> Star m a b -> Star m s t #
Traversing (->) # |
Instance details Defined in Data.Profunctor.Traversing Methods traverse' :: Traversable f => (a -> b) -> f a -> f b # wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> (a -> b) -> s -> t #
(Functor f, Traversing p) => Traversing (Tannen f p) # |
Instance details Defined in Data.Profunctor.Traversing Methods traverse' :: Traversable f0 => Tannen f p a b -> Tannen f p (f0 a) (f0 b) # wander :: (forall (f0 :: Type -> Type). Applicative f0 => (a -> f0 b) -> s -> f0 t) -> Tannen f p a b -> Tannen f p s t #
(Functor f, Traversing p) => Traversing (Cayley f p) # |
Instance details Defined in Data.Profunctor.Cayley Methods traverse' :: Traversable f0 => Cayley f p a b -> Cayley f p (f0 a) (f0 b) # wander :: (forall (f0 :: Type -> Type). Applicative f0 => (a -> f0 b) -> s -> f0 t) -> Cayley f p a b -> Cayley f p s t #
(Traversing p, Traversing q) => Traversing (Procompose p q) # |
Instance details Defined in Data.Profunctor.Composition Methods traverse' :: Traversable f => Procompose p q a b -> Procompose p q (f a) (f b) # wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> Procompose p q a b -> Procompose p q s t #

newtype CofreeTraversing (p :: Type -> Type -> Type) a b #

Constructors

CofreeTraversing |

Fields

- runCofreeTraversing :: forall (f :: Type -> Type). Traversable f => p (f a) (f b)

#### Instances

Instances details

ProfunctorComonad CofreeTraversing # |
Instance details Defined in Data.Profunctor.Traversing Methods proextract :: forall (p :: Type -> Type -> Type). Profunctor p => CofreeTraversing p :-> p # produplicate :: forall (p :: Type -> Type -> Type). Profunctor p => CofreeTraversing p :-> CofreeTraversing (CofreeTraversing p) #
ProfunctorFunctor CofreeTraversing # |
Instance details Defined in Data.Profunctor.Traversing Methods promap :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Profunctor p => (p :-> q) -> CofreeTraversing p :-> CofreeTraversing q #
Profunctor p => Choice (CofreeTraversing p) # |
Instance details Defined in Data.Profunctor.Traversing Methods left' :: CofreeTraversing p a b -> CofreeTraversing p (Either a c) (Either b c) # right' :: CofreeTraversing p a b -> CofreeTraversing p (Either c a) (Either c b) #
Profunctor p => Strong (CofreeTraversing p) # |
Instance details Defined in Data.Profunctor.Traversing Methods first' :: CofreeTraversing p a b -> CofreeTraversing p (a, c) (b, c) # second' :: CofreeTraversing p a b -> CofreeTraversing p (c, a) (c, b) #
Profunctor p => Traversing (CofreeTraversing p) # |
Instance details Defined in Data.Profunctor.Traversing Methods traverse' :: Traversable f => CofreeTraversing p a b -> CofreeTraversing p (f a) (f b) # wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> CofreeTraversing p a b -> CofreeTraversing p s t #
Profunctor p => Profunctor (CofreeTraversing p) # |

Instance details

Defined in Data.Profunctor.Traversing

Methods

dimap :: (a -> b) -> (c -> d) -> CofreeTraversing p b c -> CofreeTraversing p a d #

lmap :: (a -> b) -> CofreeTraversing p b c -> CofreeTraversing p a c #

rmap :: (b -> c) -> CofreeTraversing p a b -> CofreeTraversing p a c #

(#.) :: forall a b c q. Coercible c b => q b c -> CofreeTraversing p a b -> CofreeTraversing p a c #

(.#) :: forall a b c q. Coercible b a => CofreeTraversing p b c -> q a b -> CofreeTraversing p a c #

data FreeTraversing (p :: Type -> Type -> Type) a b where #

    FreeTraversing -| CofreeTraversing

Constructors

FreeTraversing :: forall (f :: Type -> Type) y b (p :: Type -> Type -> Type) x a. Traversable f => (f y -> b) -> p x y -> (a -> f x) -> FreeTraversing p a b |

#### Instances

Instances details

ProfunctorMonad FreeTraversing # |
Instance details Defined in Data.Profunctor.Traversing Methods proreturn :: forall (p :: Type -> Type -> Type). Profunctor p => p :-> FreeTraversing p # projoin :: forall (p :: Type -> Type -> Type). Profunctor p => FreeTraversing (FreeTraversing p) :-> FreeTraversing p #
ProfunctorFunctor FreeTraversing # |
Instance details Defined in Data.Profunctor.Traversing Methods promap :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Profunctor p => (p :-> q) -> FreeTraversing p :-> FreeTraversing q #
Choice (FreeTraversing p) # |
Instance details Defined in Data.Profunctor.Traversing Methods left' :: FreeTraversing p a b -> FreeTraversing p (Either a c) (Either b c) # right' :: FreeTraversing p a b -> FreeTraversing p (Either c a) (Either c b) #
Strong (FreeTraversing p) # |
Instance details Defined in Data.Profunctor.Traversing Methods first' :: FreeTraversing p a b -> FreeTraversing p (a, c) (b, c) # second' :: FreeTraversing p a b -> FreeTraversing p (c, a) (c, b) #
Traversing (FreeTraversing p) # |
Instance details Defined in Data.Profunctor.Traversing Methods traverse' :: Traversable f => FreeTraversing p a b -> FreeTraversing p (f a) (f b) # wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> FreeTraversing p a b -> FreeTraversing p s t #
Profunctor (FreeTraversing p) # |

Instance details

Defined in Data.Profunctor.Traversing

Methods

dimap :: (a -> b) -> (c -> d) -> FreeTraversing p b c -> FreeTraversing p a d #

lmap :: (a -> b) -> FreeTraversing p b c -> FreeTraversing p a c #

rmap :: (b -> c) -> FreeTraversing p a b -> FreeTraversing p a c #

(#.) :: forall a b c q. Coercible c b => q b c -> FreeTraversing p a b -> FreeTraversing p a c #

(.#) :: forall a b c q. Coercible b a => FreeTraversing p b c -> q a b -> FreeTraversing p a c #

Functor (FreeTraversing p a) # |
Instance details Defined in Data.Profunctor.Traversing Methods fmap :: (a0 -> b) -> FreeTraversing p a a0 -> FreeTraversing p a b # (<$) :: a0 -> FreeTraversing p a b -> FreeTraversing p a a0 #

# Profunctor in terms of Traversing

dimapWandering :: Traversing p => (a' -> a) -> (b -> b') -> p a b -> p a' b' #

A definition of `dimap` for `Traversing` instances that define an explicit `wander`.

lmapWandering :: Traversing p => (a -> b) -> p b c -> p a c #

`lmapWandering` may be a more efficient implementation of `lmap` than the default produced from `dimapWandering`.

rmapWandering :: Traversing p => (b -> c) -> p a b -> p a c #

`rmapWandering` is the same as the default produced from `dimapWandering`.

# Strong in terms of Traversing

firstTraversing :: Traversing p => p a b -> p (a, c) (b, c) #

secondTraversing :: Traversing p => p a b -> p (c, a) (c, b) #

# Choice in terms of Traversing

leftTraversing :: Traversing p => p a b -> p (Either a c) (Either b c) #

rightTraversing :: Traversing p => p a b -> p (Either c a) (Either c b) #