Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- class Bifunctor p => Biapplicative p where
- (<<$>>) :: (a -> b) -> a -> b
- (<<**>>) :: Biapplicative p => p a c -> p (a -> b) (c -> d) -> p b d
- biliftA2 :: Biapplicative w => (a -> b -> c) -> (d -> e -> f) -> w a d -> w b e -> w c f
- biliftA3 :: Biapplicative w => (a -> b -> c -> d) -> (e -> f -> g -> h) -> w a e -> w b f -> w c g -> w d h
- class Bifoldable p where
- bifoldr :: Bifoldable p => forall a c b. (a -> c -> c) -> (b -> c -> c) -> c -> p a b -> c
- bifoldl :: Bifoldable p => forall c a b. (c -> a -> c) -> (c -> b -> c) -> c -> p a b -> c
- bifoldr' :: Bifoldable t => (a -> c -> c) -> (b -> c -> c) -> c -> t a b -> c
- bifoldrM :: (Bifoldable t, Monad m) => (a -> c -> m c) -> (b -> c -> m c) -> c -> t a b -> m c
- bifoldl' :: Bifoldable t => (a -> b -> a) -> (a -> c -> a) -> a -> t b c -> a
- bifoldlM :: (Bifoldable t, Monad m) => (a -> b -> m a) -> (a -> c -> m a) -> a -> t b c -> m a
- bitraverse_ :: (Bifoldable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f ()
- bifor_ :: (Bifoldable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f ()
- bimapM_ :: (Bifoldable t, Monad m) => (a -> m c) -> (b -> m d) -> t a b -> m ()
- biforM_ :: (Bifoldable t, Monad m) => t a b -> (a -> m c) -> (b -> m d) -> m ()
- bimsum :: (Bifoldable t, MonadPlus m) => t (m a) (m a) -> m a
- bisequenceA_ :: (Bifoldable t, Applicative f) => t (f a) (f b) -> f ()
- bisequence_ :: (Bifoldable t, Monad m) => t (m a) (m b) -> m ()
- biasum :: (Bifoldable t, Alternative f) => t (f a) (f a) -> f a
- biList :: Bifoldable t => t a a -> [a]
- binull :: Bifoldable t => t a b -> Bool
- bilength :: Bifoldable t => t a b -> Int
- bielem :: (Bifoldable t, Eq a) => a -> t a a -> Bool
- bisum :: (Bifoldable t, Num a) => t a a -> a
- biproduct :: (Bifoldable t, Num a) => t a a -> a
- biand :: Bifoldable t => t Bool Bool -> Bool
- bior :: Bifoldable t => t Bool Bool -> Bool
- biany :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool
- biall :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool
- binotElem :: (Bifoldable t, Eq a) => a -> t a a -> Bool
- bifind :: Bifoldable t => (a -> Bool) -> t a a -> Maybe a
- data Biff k k1 k2 k3 p f g a b :: forall k k1 k2 k3. (k3 -> k2 -> *) -> (k1 -> k3) -> (k -> k2) -> k1 -> k -> *
- data Biff k k1 k2 k3 p f g a b :: forall k k1 k2 k3. (k3 -> k2 -> *) -> (k1 -> k3) -> (k -> k2) -> k1 -> k -> *
- data Clown k k1 f a b :: forall k k1. (k1 -> *) -> k1 -> k -> *
- data Clown k k1 f a b :: forall k k1. (k1 -> *) -> k1 -> k -> *
- data Fix k p a :: forall k. (* -> k -> *) -> k -> *
- data Fix k p a :: forall k. (* -> k -> *) -> k -> *
- data Flip k k1 p a b :: forall k k1. (k1 -> k -> *) -> k -> k1 -> *
- data Flip k k1 p a b :: forall k k1. (k1 -> k -> *) -> k -> k1 -> *
- class BifunctorFunctor k k1 k2 k3 t where
- class BifunctorFunctor k k1 k k1 t => BifunctorMonad k k1 t where
- biliftM :: BifunctorMonad k k1 t => (:->) k k1 p q -> (:->) k k1 (t p) (t q)
- class BifunctorFunctor k k1 k k1 t => BifunctorComonad k k1 t where
- biliftW :: BifunctorComonad k k1 t => (:->) k k1 p q -> (:->) k k1 (t p) (t q)
- newtype Join k p a :: forall k. (k -> k -> *) -> k -> * = Join {
- runJoin :: p a a
- newtype Joker k k1 g a b :: forall k k1. (k1 -> *) -> k -> k1 -> * = Joker {
- runJoker :: g b
- newtype Tannen k k1 k2 f p a b :: forall k k1 k2. (k2 -> *) -> (k1 -> k -> k2) -> k1 -> k -> * = Tannen {
- runTannen :: f (p a b)
- newtype WrappedBifunctor k k1 p a b :: forall k k1. (k1 -> k -> *) -> k1 -> k -> * = WrapBifunctor {
- unwrapBifunctor :: p a b
- class (Bifunctor t, Bifoldable t) => Bitraversable t where
- bisequenceA :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b)
- bisequence :: (Bitraversable t, Monad m) => t (m a) (m b) -> m (t a b)
- bimapM :: (Bitraversable t, Monad m) => (a -> m c) -> (b -> m d) -> t a b -> m (t c d)
- bifor :: (Bitraversable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f (t c d)
- biforM :: (Bitraversable t, Monad m) => t a b -> (a -> m c) -> (b -> m d) -> m (t c d)
- bimapAccumL :: Bitraversable t => (a -> b -> (a, c)) -> (a -> d -> (a, e)) -> a -> t b d -> (a, t c e)
- bimapAccumR :: Bitraversable t => (a -> b -> (a, c)) -> (a -> d -> (a, e)) -> a -> t b d -> (a, t c e)
- bimapDefault :: Bitraversable t => (a -> b) -> (c -> d) -> t a c -> t b d
- bifoldMapDefault :: (Bitraversable t, Monoid m) => (a -> m) -> (b -> m) -> t a b -> m
Documentation
class Bifunctor p => Biapplicative p where #
(<<*>>) :: p (a -> b) (c -> d) -> p a c -> p b d infixl 4 #
Biapplicative (,) | |
Biapplicative Arg | |
Monoid x => Biapplicative ((,,) x) | |
Biapplicative (Const *) | |
Biapplicative (Tagged *) | |
(Monoid x, Monoid y) => Biapplicative ((,,,) x y) | |
(Monoid x, Monoid y, Monoid z) => Biapplicative ((,,,,) x y z) | |
Biapplicative p => Biapplicative (WrappedBifunctor * * p) | |
Applicative g => Biapplicative (Joker * * g) | |
Biapplicative p => Biapplicative (Flip * * p) | |
Applicative f => Biapplicative (Clown * * f) | |
(Monoid x, Monoid y, Monoid z, Monoid w) => Biapplicative ((,,,,,) x y z w) | |
(Monoid x, Monoid y, Monoid z, Monoid w, Monoid v) => Biapplicative ((,,,,,,) x y z w v) | |
(Applicative f, Biapplicative p) => Biapplicative (Tannen * * * f p) | |
(Biapplicative p, Applicative f, Applicative g) => Biapplicative (Biff * * * * p f g) | |
(<<**>>) :: Biapplicative p => p a c -> p (a -> b) (c -> d) -> p b d infixl 4 #
biliftA2 :: Biapplicative w => (a -> b -> c) -> (d -> e -> f) -> w a d -> w b e -> w c f #
Lift binary functions
biliftA3 :: Biapplicative w => (a -> b -> c -> d) -> (e -> f -> g -> h) -> w a e -> w b f -> w c g -> w d h #
Lift ternary functions
class Bifoldable p where #
Bifoldable
identifies foldable structures with two different varieties
of elements (as opposed to Foldable
, which has one variety of element).
Common examples are Either
and '(,)':
instance Bifoldable Either where bifoldMap f _ (Left a) = f a bifoldMap _ g (Right b) = g b instance Bifoldable (,) where bifoldr f g z (a, b) = f a (g b z)
A minimal Bifoldable
definition consists of either bifoldMap
or
bifoldr
. When defining more than this minimal set, one should ensure
that the following identities hold:
bifold
≡bifoldMap
id
id
bifoldMap
f g ≡bifoldr
(mappend
. f) (mappend
. g)mempty
bifoldr
f g z t ≡appEndo
(bifoldMap
(Endo . f) (Endo . g) t) z
If the type is also a Bifunctor
instance, it should satisfy:
'bifoldMap' f g ≡ 'bifold' . 'bimap' f g
which implies that
'bifoldMap' f g . 'bimap' h i ≡ 'bifoldMap' (f . h) (g . i)
bifold :: Monoid m => p m m -> m #
bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> p a b -> m #
Combines the elements of a structure, given ways of mapping them to a common monoid.
bifoldMap
f g ≡bifoldr
(mappend
. f) (mappend
. g)mempty
bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> p a b -> c #
Combines the elements of a structure in a right associative manner. Given
a hypothetical function toEitherList :: p a b -> [Either a b]
yielding a
list of all elements of a structure in order, the following would hold:
bifoldr
f g z ≡foldr
(either
f g) z . toEitherList
bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> p a b -> c #
Combines the elments of a structure in a left associative manner. Given a
hypothetical function toEitherList :: p a b -> [Either a b]
yielding a
list of all elements of a structure in order, the following would hold:
bifoldl
f g z ≡foldl
(acc ->either
(f acc) (g acc)) z . toEitherList
Note that if you want an efficient left-fold, you probably want to use
bifoldl'
instead of bifoldl
. The reason is that the latter does not
force the "inner" results, resulting in a thunk chain which then must be
evaluated from the outside-in.
Bifoldable Either | |
Bifoldable (,) | |
Bifoldable Arg | |
Bifoldable (K1 i) | |
Bifoldable ((,,) x) | |
Bifoldable (Const *) | |
Bifoldable (Tagged *) | |
Bifoldable (Constant *) | |
Bifoldable ((,,,) x y) | |
Bifoldable ((,,,,) x y z) | |
Bifoldable p => Bifoldable (WrappedBifunctor * * p) | |
Foldable g => Bifoldable (Joker * * g) | |
Bifoldable p => Bifoldable (Flip * * p) | |
Foldable f => Bifoldable (Clown * * f) | |
Bifoldable ((,,,,,) x y z w) | |
Bifoldable ((,,,,,,) x y z w v) | |
(Foldable f, Bifoldable p) => Bifoldable (Tannen * * * f p) | |
(Bifoldable p, Foldable f, Foldable g) => Bifoldable (Biff * * * * p f g) | |
bifoldr :: Bifoldable p => forall a c b. (a -> c -> c) -> (b -> c -> c) -> c -> p a b -> c #
bifoldl :: Bifoldable p => forall c a b. (c -> a -> c) -> (c -> b -> c) -> c -> p a b -> c #
Combines the elments of a structure in a left associative manner. Given a
hypothetical function toEitherList :: p a b -> [Either a b]
yielding a
list of all elements of a structure in order, the following would hold:
bifoldl
f g z ≡foldl
(acc ->either
(f acc) (g acc)) z . toEitherList
Note that if you want an efficient left-fold, you probably want to use
bifoldl'
instead of bifoldl
. The reason is that the latter does not
force the "inner" results, resulting in a thunk chain which then must be
evaluated from the outside-in.
bifoldr' :: Bifoldable t => (a -> c -> c) -> (b -> c -> c) -> c -> t a b -> c #
As bifoldr
, but strict in the result of the reduction functions at each
step.
bifoldrM :: (Bifoldable t, Monad m) => (a -> c -> m c) -> (b -> c -> m c) -> c -> t a b -> m c #
Right associative monadic bifold over a structure.
bifoldl' :: Bifoldable t => (a -> b -> a) -> (a -> c -> a) -> a -> t b c -> a #
As bifoldl
, but strict in the result of the reduction functions at each
step.
This ensures that each step of the bifold is forced to weak head normal form
before being applied, avoiding the collection of thunks that would otherwise
occur. This is often what you want to strictly reduce a finite structure to
a single, monolithic result (e.g., bilength
).
bifoldlM :: (Bifoldable t, Monad m) => (a -> b -> m a) -> (a -> c -> m a) -> a -> t b c -> m a #
Left associative monadic bifold over a structure.
bitraverse_ :: (Bifoldable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f () #
Map each element of a structure using one of two actions, evaluate these
actions from left to right, and ignore the results. For a version that
doesn't ignore the results, see bitraverse
.
bifor_ :: (Bifoldable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f () #
As bitraverse_
, but with the structure as the primary argument. For a
version that doesn't ignore the results, see bifor
.
>>>
> bifor_ ('a', "bc") print (print . reverse)
'a' "cb"
bimapM_ :: (Bifoldable t, Monad m) => (a -> m c) -> (b -> m d) -> t a b -> m () #
As bimapM
, but ignores the results of the functions,
merely performing the "actions".
biforM_ :: (Bifoldable t, Monad m) => t a b -> (a -> m c) -> (b -> m d) -> m () #
As bimapM_
, but with the structure as the primary argument.
bimsum :: (Bifoldable t, MonadPlus m) => t (m a) (m a) -> m a #
The sum of a collection of actions, generalizing biconcat
.
bisequenceA_ :: (Bifoldable t, Applicative f) => t (f a) (f b) -> f () #
As bisequenceA
, but ignores the results of the actions.
bisequence_ :: (Bifoldable t, Monad m) => t (m a) (m b) -> m () #
Evaluate each action in the structure from left to right, and ignore the
results. For a version that doesn't ignore the results, see
bisequence
.
biasum :: (Bifoldable t, Alternative f) => t (f a) (f a) -> f a #
The sum of a collection of actions, generalizing biconcat
.
biList :: Bifoldable t => t a a -> [a] #
Collects the list of elements of a structure, from left to right.
binull :: Bifoldable t => t a b -> Bool #
Test whether the structure is empty.
bilength :: Bifoldable t => t a b -> Int #
Returns the size/length of a finite structure as an Int
.
bielem :: (Bifoldable t, Eq a) => a -> t a a -> Bool #
Does the element occur in the structure?
bisum :: (Bifoldable t, Num a) => t a a -> a #
The bisum
function computes the sum of the numbers of a structure.
biproduct :: (Bifoldable t, Num a) => t a a -> a #
The biproduct
function computes the product of the numbers of a
structure.
biany :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool #
Determines whether any element of the structure satisfies the appropriate predicate.
biall :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool #
Determines whether all elements of the structure satisfy the appropriate predicate.
bifind :: Bifoldable t => (a -> Bool) -> t a a -> Maybe a #
data Biff k k1 k2 k3 p f g a b :: forall k k1 k2 k3. (k3 -> k2 -> *) -> (k1 -> k3) -> (k -> k2) -> k1 -> k -> * #
(Bifunctor p, Functor f, Functor g) => Bifunctor (Biff * * * * p f g) | |
(Biapplicative p, Applicative f, Applicative g) => Biapplicative (Biff * * * * p f g) | |
(Bitraversable p, Traversable f, Traversable g) => Bitraversable (Biff * * * * p f g) | |
(Bifoldable p, Foldable f, Foldable g) => Bifoldable (Biff * * * * p f g) | |
(Bifunctor p, Functor g) => Functor (Biff * k * * p f g a) | |
(Bifoldable p, Foldable g) => Foldable (Biff * k * * p f g a) | |
(Bitraversable p, Traversable g) => Traversable (Biff * k * * p f g a) | |
Functor (p (f a)) => Generic1 (Biff * k * k1 p f g a) | |
Eq (p (f a) (g b)) => Eq (Biff k3 k2 k1 k p f g a b) | |
Ord (p (f a) (g b)) => Ord (Biff k3 k2 k1 k p f g a b) | |
Read (p (f a) (g b)) => Read (Biff k3 k2 k1 k p f g a b) | |
Show (p (f a) (g b)) => Show (Biff k3 k2 k1 k p f g a b) | |
Generic (Biff k3 k2 k1 k p f g a b) | |
type Rep1 (Biff * k1 * k p f g a) | |
type Rep (Biff k3 k2 k1 k p f g a b) | |
data Biff k k1 k2 k3 p f g a b :: forall k k1 k2 k3. (k3 -> k2 -> *) -> (k1 -> k3) -> (k -> k2) -> k1 -> k -> * #
(Bifunctor p, Functor f, Functor g) => Bifunctor (Biff * * * * p f g) | |
(Biapplicative p, Applicative f, Applicative g) => Biapplicative (Biff * * * * p f g) | |
(Bitraversable p, Traversable f, Traversable g) => Bitraversable (Biff * * * * p f g) | |
(Bifoldable p, Foldable f, Foldable g) => Bifoldable (Biff * * * * p f g) | |
(Bifunctor p, Functor g) => Functor (Biff * k * * p f g a) | |
(Bifoldable p, Foldable g) => Foldable (Biff * k * * p f g a) | |
(Bitraversable p, Traversable g) => Traversable (Biff * k * * p f g a) | |
Functor (p (f a)) => Generic1 (Biff * k * k1 p f g a) | |
Eq (p (f a) (g b)) => Eq (Biff k3 k2 k1 k p f g a b) | |
Ord (p (f a) (g b)) => Ord (Biff k3 k2 k1 k p f g a b) | |
Read (p (f a) (g b)) => Read (Biff k3 k2 k1 k p f g a b) | |
Show (p (f a) (g b)) => Show (Biff k3 k2 k1 k p f g a b) | |
Generic (Biff k3 k2 k1 k p f g a b) | |
type Rep1 (Biff * k1 * k p f g a) | |
type Rep (Biff k3 k2 k1 k p f g a b) | |
data Clown k k1 f a b :: forall k k1. (k1 -> *) -> k1 -> k -> * #
Make a Functor
over the first argument of a Bifunctor
.
Mnemonic: Clowns to the left (parameter of the Bifunctor), jokers to the right.
Functor f => Bifunctor (Clown * * f) | |
Applicative f => Biapplicative (Clown * * f) | |
Traversable f => Bitraversable (Clown * * f) | |
Foldable f => Bifoldable (Clown * * f) | |
Functor (Clown * k f a) | |
Foldable (Clown * k f a) | |
Traversable (Clown * k f a) | |
Generic1 (Clown * k f a) | |
Eq (f a) => Eq (Clown k1 k f a b) | |
Ord (f a) => Ord (Clown k1 k f a b) | |
Read (f a) => Read (Clown k1 k f a b) | |
Show (f a) => Show (Clown k1 k f a b) | |
Generic (Clown k1 k f a b) | |
type Rep1 (Clown * k f a) | |
type Rep (Clown k1 k f a b) | |
data Clown k k1 f a b :: forall k k1. (k1 -> *) -> k1 -> k -> * #
Make a Functor
over the first argument of a Bifunctor
.
Mnemonic: Clowns to the left (parameter of the Bifunctor), jokers to the right.
Functor f => Bifunctor (Clown * * f) | |
Applicative f => Biapplicative (Clown * * f) | |
Traversable f => Bitraversable (Clown * * f) | |
Foldable f => Bifoldable (Clown * * f) | |
Functor (Clown * k f a) | |
Foldable (Clown * k f a) | |
Traversable (Clown * k f a) | |
Generic1 (Clown * k f a) | |
Eq (f a) => Eq (Clown k1 k f a b) | |
Ord (f a) => Ord (Clown k1 k f a b) | |
Read (f a) => Read (Clown k1 k f a b) | |
Show (f a) => Show (Clown k1 k f a b) | |
Generic (Clown k1 k f a b) | |
type Rep1 (Clown * k f a) | |
type Rep (Clown k1 k f a b) | |
data Fix k p a :: forall k. (* -> k -> *) -> k -> * #
Bifunctor p => Functor (Fix * p) | |
Biapplicative p => Applicative (Fix * p) | |
Bifoldable p => Foldable (Fix * p) | |
Bitraversable p => Traversable (Fix * p) | |
Eq (p (Fix k p a) a) => Eq (Fix k p a) | |
Ord (p (Fix k p a) a) => Ord (Fix k p a) | |
Read (p (Fix k p a) a) => Read (Fix k p a) | |
Show (p (Fix k p a) a) => Show (Fix k p a) | |
Generic (Fix k p a) | |
type Rep (Fix k p a) | |
data Fix k p a :: forall k. (* -> k -> *) -> k -> * #
Bifunctor p => Functor (Fix * p) | |
Biapplicative p => Applicative (Fix * p) | |
Bifoldable p => Foldable (Fix * p) | |
Bitraversable p => Traversable (Fix * p) | |
Eq (p (Fix k p a) a) => Eq (Fix k p a) | |
Ord (p (Fix k p a) a) => Ord (Fix k p a) | |
Read (p (Fix k p a) a) => Read (Fix k p a) | |
Show (p (Fix k p a) a) => Show (Fix k p a) | |
Generic (Fix k p a) | |
type Rep (Fix k p a) | |
data Flip k k1 p a b :: forall k k1. (k1 -> k -> *) -> k -> k1 -> * #
BifunctorFunctor k1 k k k1 (Flip k k1) | |
Bifunctor p => Bifunctor (Flip * * p) | |
Biapplicative p => Biapplicative (Flip * * p) | |
Bitraversable p => Bitraversable (Flip * * p) | |
Bifoldable p => Bifoldable (Flip * * p) | |
Bifunctor p => Functor (Flip * * p a) | |
Bifoldable p => Foldable (Flip * * p a) | |
Bitraversable p => Traversable (Flip * * p a) | |
Eq (p b a) => Eq (Flip k k1 p a b) | |
Ord (p b a) => Ord (Flip k k1 p a b) | |
Read (p b a) => Read (Flip k k1 p a b) | |
Show (p b a) => Show (Flip k k1 p a b) | |
Generic (Flip k k1 p a b) | |
type Rep (Flip k k1 p a b) | |
data Flip k k1 p a b :: forall k k1. (k1 -> k -> *) -> k -> k1 -> * #
BifunctorFunctor k1 k k k1 (Flip k k1) | |
Bifunctor p => Bifunctor (Flip * * p) | |
Biapplicative p => Biapplicative (Flip * * p) | |
Bitraversable p => Bitraversable (Flip * * p) | |
Bifoldable p => Bifoldable (Flip * * p) | |
Bifunctor p => Functor (Flip * * p a) | |
Bifoldable p => Foldable (Flip * * p a) | |
Bitraversable p => Traversable (Flip * * p a) | |
Eq (p b a) => Eq (Flip k k1 p a b) | |
Ord (p b a) => Ord (Flip k k1 p a b) | |
Read (p b a) => Read (Flip k k1 p a b) | |
Show (p b a) => Show (Flip k k1 p a b) | |
Generic (Flip k k1 p a b) | |
type Rep (Flip k k1 p a b) | |
class BifunctorFunctor k k1 k2 k3 t where #
BifunctorFunctor k1 k k k1 (Flip k k1) | |
Functor f => BifunctorFunctor k k1 k k1 (Tannen k k1 * f) | |
class BifunctorFunctor k k1 k k1 t => BifunctorMonad k k1 t where #
(Functor f, Monad f) => BifunctorMonad k k1 (Tannen k k1 * f) | |
biliftM :: BifunctorMonad k k1 t => (:->) k k1 p q -> (:->) k k1 (t p) (t q) #
class BifunctorFunctor k k1 k k1 t => BifunctorComonad k k1 t where #
biextract, (biextend | biduplicate)
biextract :: t p a b -> p a b #
biextend :: (:->) k k1 (t p) q -> (:->) k k1 (t p) (t q) #
biduplicate :: t p a b -> t (t p) a b #
Comonad f => BifunctorComonad k k1 (Tannen k k1 * f) | |
biliftW :: BifunctorComonad k k1 t => (:->) k k1 p q -> (:->) k k1 (t p) (t q) #
newtype Join k p a :: forall k. (k -> k -> *) -> k -> * #
Bifunctor p => Functor (Join * p) | |
Biapplicative p => Applicative (Join * p) | |
Bifoldable p => Foldable (Join * p) | |
Bitraversable p => Traversable (Join * p) | |
Eq (p a a) => Eq (Join k p a) | |
Ord (p a a) => Ord (Join k p a) | |
Read (p a a) => Read (Join k p a) | |
Show (p a a) => Show (Join k p a) | |
Generic (Join k p a) | |
type Rep (Join k p a) | |
newtype Joker k k1 g a b :: forall k k1. (k1 -> *) -> k -> k1 -> * #
Make a Functor
over the second argument of a Bifunctor
.
Mnemonic: Clowns to the left (parameter of the Bifunctor), jokers to the right.
Functor g => Bifunctor (Joker * * g) | |
Applicative g => Biapplicative (Joker * * g) | |
Traversable g => Bitraversable (Joker * * g) | |
Foldable g => Bifoldable (Joker * * g) | |
Functor g => Functor (Joker k * g a) | |
Foldable g => Foldable (Joker k * g a) | |
Traversable g => Traversable (Joker k * g a) | |
Generic1 (Joker k * g a) | |
Eq (g b) => Eq (Joker k1 k g a b) | |
Ord (g b) => Ord (Joker k1 k g a b) | |
Read (g b) => Read (Joker k1 k g a b) | |
Show (g b) => Show (Joker k1 k g a b) | |
Generic (Joker k1 k g a b) | |
type Rep1 (Joker k * g a) | |
type Rep (Joker k1 k g a b) | |
newtype Tannen k k1 k2 f p a b :: forall k k1 k2. (k2 -> *) -> (k1 -> k -> k2) -> k1 -> k -> * #
newtype WrappedBifunctor k k1 p a b :: forall k k1. (k1 -> k -> *) -> k1 -> k -> * #
WrapBifunctor | |
|
Bifunctor p => Bifunctor (WrappedBifunctor * * p) | |
Biapplicative p => Biapplicative (WrappedBifunctor * * p) | |
Bitraversable p => Bitraversable (WrappedBifunctor * * p) | |
Bifoldable p => Bifoldable (WrappedBifunctor * * p) | |
Bifunctor p => Functor (WrappedBifunctor * * p a) | |
Bifoldable p => Foldable (WrappedBifunctor * * p a) | |
Bitraversable p => Traversable (WrappedBifunctor * * p a) | |
Generic1 (WrappedBifunctor * k p a) | |
Eq (p a b) => Eq (WrappedBifunctor k1 k p a b) | |
Ord (p a b) => Ord (WrappedBifunctor k1 k p a b) | |
Read (p a b) => Read (WrappedBifunctor k1 k p a b) | |
Show (p a b) => Show (WrappedBifunctor k1 k p a b) | |
Generic (WrappedBifunctor k1 k p a b) | |
type Rep1 (WrappedBifunctor * k p a) | |
type Rep (WrappedBifunctor k1 k p a b) | |
class (Bifunctor t, Bifoldable t) => Bitraversable t where #
Bitraversable
identifies bifunctorial data structures whose elements can
be traversed in order, performing Applicative
or Monad
actions at each
element, and collecting a result structure with the same shape.
As opposed to Traversable
data structures, which have one variety of
element on which an action can be performed, Bitraversable
data structures
have two such varieties of elements.
A definition of bitraverse
must satisfy the following laws:
- naturality
for every applicative transformationbitraverse
(t . f) (t . g) ≡ t .bitraverse
f gt
- identity
bitraverse
Identity
Identity
≡Identity
- composition
Compose
.fmap
(bitraverse
g1 g2) .bitraverse
f1 f2 ≡traverse
(Compose
.fmap
g1 . f1) (Compose
.fmap
g2 . f2)
where an applicative transformation is a function
t :: (Applicative
f,Applicative
g) => f a -> g a
preserving the Applicative
operations:
t (pure
x) =pure
x t (f<*>
x) = t f<*>
t x
and the identity functor Identity
and composition functors Compose
are
defined as
newtype Identity a = Identity { runIdentity :: a } instance Functor Identity where fmap f (Identity x) = Identity (f x) instance Applicative Identity where pure = Identity Identity f <*> Identity x = Identity (f x) newtype Compose f g a = Compose (f (g a)) instance (Functor f, Functor g) => Functor (Compose f g) where fmap f (Compose x) = Compose (fmap (fmap f) x) instance (Applicative f, Applicative g) => Applicative (Compose f g) where pure = Compose . pure . pure Compose f <*> Compose x = Compose ((<*>) <$> f <*> x)
Some simple examples are Either
and '(,)':
instance Bitraversable Either where bitraverse f _ (Left x) = Left <$> f x bitraverse _ g (Right y) = Right <$> g y instance Bitraversable (,) where bitraverse f g (x, y) = (,) <$> f x <*> g y
Bitraversable
relates to its superclasses in the following ways:
bimap
f g ≡runIdentity
.bitraverse
(Identity
. f) (Identity
. g)bifoldMap
f g =getConst
.bitraverse
(Const
. f) (Const
. g)
These are available as bimapDefault
and bifoldMapDefault
respectively.
bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> t a b -> f (t c d) #
Evaluates the relevant functions at each element in the structure, running the action, and builds a new structure with the same shape, using the elements produced from sequencing the actions.
bitraverse
f g ≡bisequenceA
.bimap
f g
For a version that ignores the results, see bitraverse_
.
Bitraversable Either | |
Bitraversable (,) | |
Bitraversable Arg | |
Bitraversable (K1 i) | |
Bitraversable ((,,) x) | |
Bitraversable (Const *) | |
Bitraversable (Tagged *) | |
Bitraversable (Constant *) | |
Bitraversable ((,,,) x y) | |
Bitraversable ((,,,,) x y z) | |
Bitraversable p => Bitraversable (WrappedBifunctor * * p) | |
Traversable g => Bitraversable (Joker * * g) | |
Bitraversable p => Bitraversable (Flip * * p) | |
Traversable f => Bitraversable (Clown * * f) | |
Bitraversable ((,,,,,) x y z w) | |
Bitraversable ((,,,,,,) x y z w v) | |
(Traversable f, Bitraversable p) => Bitraversable (Tannen * * * f p) | |
(Bitraversable p, Traversable f, Traversable g) => Bitraversable (Biff * * * * p f g) | |
bisequenceA :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b) #
Sequences all the actions in a structure, building a new structure with the
same shape using the results of the actions. For a version that ignores the
results, see bisequenceA_
.
bisequenceA
≡bitraverse
id
id
bisequence :: (Bitraversable t, Monad m) => t (m a) (m b) -> m (t a b) #
As bisequenceA
, but uses evidence that m
is a Monad
rather than an
Applicative
. For a version that ignores the results, see bisequence_
.
bisequence
≡bimapM
id
id
bisequence
≡unwrapMonad
.bisequenceA
.bimap
WrapMonad
WrapMonad
bimapM :: (Bitraversable t, Monad m) => (a -> m c) -> (b -> m d) -> t a b -> m (t c d) #
As bitraverse
, but uses evidence that m
is a Monad
rather than an
Applicative
. For a version that ignores the results, see bimapM_
.
bimapM
f g ≡bisequence
.bimap
f gbimapM
f g ≡unwrapMonad
.bitraverse
(WrapMonad
. f) (WrapMonad
. g)
bifor :: (Bitraversable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f (t c d) #
bifor
is bitraverse
with the structure as the first argument. For a
version that ignores the results, see bifor_
.
biforM :: (Bitraversable t, Monad m) => t a b -> (a -> m c) -> (b -> m d) -> m (t c d) #
bimapAccumL :: Bitraversable t => (a -> b -> (a, c)) -> (a -> d -> (a, e)) -> a -> t b d -> (a, t c e) #
The bimapAccumL
function behaves like a combination of bimap
and
bifoldl
; it traverses a structure from left to right, threading a state
of type a
and using the given actions to compute new elements for the
structure.
bimapAccumR :: Bitraversable t => (a -> b -> (a, c)) -> (a -> d -> (a, e)) -> a -> t b d -> (a, t c e) #
The bimapAccumR
function behaves like a combination of bimap
and
bifoldl
; it traverses a structure from right to left, threading a state
of type a
and using the given actions to compute new elements for the
structure.
bimapDefault :: Bitraversable t => (a -> b) -> (c -> d) -> t a c -> t b d #
A default definition of bimap
in terms of the Bitraversable
operations.
bimapDefault
f g ≡runIdentity
.bitraverse
(Identity
. f) (Identity
. g)
bifoldMapDefault :: (Bitraversable t, Monoid m) => (a -> m) -> (b -> m) -> t a b -> m #
A default definition of bifoldMap
in terms of the Bitraversable
operations.
bifoldMapDefault
f g ≡getConst
.bitraverse
(Const
. f) (Const
. g)