Community
Modules 14

Data.Biapplicative

provisional
1 generation diagnostics
  • unattached documentation comment at 187:1

Biapplicative bifunctors

class Bifunctor p => Biapplicative p

(<<*>>) :: p (a -> b) (c -> d) -> p a c -> p b d

biliftA2 :: (a -> b -> c) -> (d -> e -> f) -> p a d -> p b e -> p c f

Lift binary functions

(*>>) :: p a b -> p c d -> p c d

a '*>>' b ≡ 'bimap' ('const' 'id') ('const' 'id') '<<$>>' a '<<*>>' b

(<<*) :: p a b -> p c d -> p a b

a '<<*' b ≡ 'bimap' 'const' 'const' '<<$>>' a '<<*>>' b

(<<**>>) :: Biapplicative p => p a c -> p (a -> b) (c -> d) -> p b d

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

traverseBia :: (Traversable t, Biapplicative p) => (a -> p b c) -> t a -> p (t b) (t c)

Traverse a Traversable container in a Biapplicative.

traverseBia satisfies the following properties:

Pairing

traverseBia (,) t = (t, t)

Composition

traverseBia (Biff . bimap g h . f) = Biff . bimap (traverse g) (traverse h) . traverseBia f

traverseBia (Tannen . fmap f . g) = Tannen . fmap (traverseBia f) . traverse g

Naturality

t . traverseBia f = traverseBia (t . f)

for every biapplicative transformation t.

A biapplicative transformation from a Biapplicative P to a Biapplicative Q is a function

t :: P a b -> Q a b

preserving the Biapplicative operations. That is,

  • t (bipure x y) = bipure x y

  • t (x <<*>> y) = t x <<*>> t y

Performance note

traverseBia is fairly efficient, and uses compiler rewrite rules to be even more efficient for a few important types like []. However, if performance is critical, you might consider writing a container-specific implementation.

sequenceBia :: (Traversable t, Biapplicative p) => t (p b c) -> p (t b) (t c)

Perform all the Biapplicative actions in a Traversable container and produce a container with all the results.

sequenceBia = 'traverseBia' id

traverseBiaWith :: forall p a b c s t. Biapplicative p => (forall f x. Applicative f => (a -> f x) -> s -> f (t x)) -> (a -> p b c) -> s -> p (t b) (t c)

A version of traverseBia that doesn't care how the traversal is done.

'traverseBia' = traverseBiaWith traverse
module Data.Bifunctor aihc-base-4.21.2.0 · 1 declaration

class Bifunctor (p :: Type -> Type -> Type)

bimap :: (a -> b) -> (c -> d) -> p a c -> p b d

first :: (a -> b) -> p a c -> p b c

second :: (b -> c) -> p a b -> p a c

Instances

11
  • instance Functor (Mag a b)
  • instance Applicative (Mag a b)
  • instance Biapplicative (,)
  • instance Biapplicative Arg
  • instance Monoid x => Biapplicative ((,,) x)
  • instance (Monoid x, Monoid y) => Biapplicative ((,,,) x y)
  • instance (Monoid x, Monoid y, Monoid z) => Biapplicative ((,,,,) x y z)
  • instance (Monoid x, Monoid y, Monoid z, Monoid w) => Biapplicative ((,,,,,) x y z w)
  • instance (Monoid x, Monoid y, Monoid z, Monoid w, Monoid v) => Biapplicative ((,,,,,,) x y z w v)
  • instance Biapplicative Tagged
  • instance Biapplicative Const
Maintainer
Edward Kmett <ekmett@gmail.com>
Portability
portable
Copyright
(C) 2011-2015 Edward Kmett
License
BSD-style (see the file LICENSE)
Build record and source files

Community contribution. The service has not verified this documentation. The generator reported 2 diagnostics.

Target: Linux on x86-64. Some inferred types and resolved links are not available.

Generator: aihc-haddock-aa6debbd-web-3

Metadata snapshot: 09b82df928e064b0f451e3d0573302709a7badfc69fe1ca8110c8d45f2c2865f

Open the dependency plan · Download the documentation model

Import a package

Enter a package name and an exact version from Hackage. The site contains imported versions only.