bifunctors-5.6.2: Bifunctors

Copyright | (C) 2008-2016 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | provisional
Portability | portable
Safe Haskell | Trustworthy
Language | Haskell2010

Data.Bifunctor.Biap

Description

Synopsis

- newtype Biap (bi :: Type -> Type -> Type) a b = Biap {
  - getBiap :: bi a b
  }

# Documentation

newtype Biap (bi :: Type -> Type -> Type) a b Source #

Pointwise lifting of a class over two arguments, using `Biapplicative`.

Classes that can be lifted include `Monoid`, `Num` and `Bounded`. Each method of those classes can be defined as lifting themselves over each argument of `Biapplicative`.

    mempty        = bipure mempty          mempty
    minBound      = bipure minBound        minBound
    maxBound      = bipure maxBound        maxBound
    fromInteger n = bipure (fromInteger n) (fromInteger n)

    negate = bimap negate negate

    (+)  = biliftA2 (+)  (+)
    (<>) = biliftA2 (<>) (<>)

`Biap` is to `Biapplicative` as `Ap` is to `Applicative`.

`Biap` can be used with `DerivingVia` to derive a numeric instance for pairs:

    newtype Numpair a = Np (a, a)
     deriving (S.Semigroup, Monoid, Num, Bounded)
     via Biap (,) a a

Constructors

Biap |

Fields

- getBiap :: bi a b

#### Instances

Instances details

Generic1 (Biap bi a :: Type -> Type) Source # |

Instance details

Defined in Data.Bifunctor.Biap

Associated Types

type Rep1 (Biap bi a :: Type -> Type) |
Instance details Defined in Data.Bifunctor.Biap type Rep1 (Biap bi a :: Type -> Type) = D1 ('MetaData "Biap" "Data.Bifunctor.Biap" "bifunctors-5.6.2-4kXyA9Yl2Ys9aGae1sUdxu" 'True) (C1 ('MetaCons "Biap" 'PrefixI 'True) (S1 ('MetaSel ('Just "getBiap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 (bi a))))

Methods

from1 :: Biap bi a a0 -> Rep1 (Biap bi a) a0 Source #

to1 :: Rep1 (Biap bi a) a0 -> Biap bi a a0 Source #

Bifoldable bi => Bifoldable (Biap bi) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods bifold :: Monoid m => Biap bi m m -> m Source # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Biap bi a b -> m Source # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Biap bi a b -> c Source # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Biap bi a b -> c Source #
Bifunctor bi => Bifunctor (Biap bi) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods bimap :: (a -> b) -> (c -> d) -> Biap bi a c -> Biap bi b d Source # first :: (a -> b) -> Biap bi a c -> Biap bi b c Source # second :: (b -> c) -> Biap bi a b -> Biap bi a c Source #
Bitraversable bi => Bitraversable (Biap bi) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Biap bi a b -> f (Biap bi c d) Source #
Eq2 bi => Eq2 (Biap bi) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Biap bi a c -> Biap bi b d -> Bool Source #
Ord2 bi => Ord2 (Biap bi) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Biap bi a c -> Biap bi b d -> Ordering Source #
Biapplicative bi => Biapplicative (Biap bi) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods bipure :: a -> b -> Biap bi a b Source # (<<*>>) :: Biap bi (a -> b) (c -> d) -> Biap bi a c -> Biap bi b d Source # biliftA2 :: (a -> b -> c) -> (d -> e -> f) -> Biap bi a d -> Biap bi b e -> Biap bi c f Source # (*>>) :: Biap bi a b -> Biap bi c d -> Biap bi c d Source # (<<*) :: Biap bi a b -> Biap bi c d -> Biap bi a b Source #
Eq1 (bi a) => Eq1 (Biap bi a) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods liftEq :: (a0 -> b -> Bool) -> Biap bi a a0 -> Biap bi a b -> Bool Source #
Ord1 (bi a) => Ord1 (Biap bi a) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods liftCompare :: (a0 -> b -> Ordering) -> Biap bi a a0 -> Biap bi a b -> Ordering Source #
Alternative (bi a) => Alternative (Biap bi a) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods empty :: Biap bi a a0 Source # (<|>) :: Biap bi a a0 -> Biap bi a a0 -> Biap bi a a0 Source # some :: Biap bi a a0 -> Biap bi a [a0] Source # many :: Biap bi a a0 -> Biap bi a [a0] Source #
Applicative (bi a) => Applicative (Biap bi a) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods pure :: a0 -> Biap bi a a0 Source # (<*>) :: Biap bi a (a0 -> b) -> Biap bi a a0 -> Biap bi a b Source # liftA2 :: (a0 -> b -> c) -> Biap bi a a0 -> Biap bi a b -> Biap bi a c Source # (*>) :: Biap bi a a0 -> Biap bi a b -> Biap bi a b Source # (<*) :: Biap bi a a0 -> Biap bi a b -> Biap bi a a0 Source #
Functor (bi a) => Functor (Biap bi a) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods fmap :: (a0 -> b) -> Biap bi a a0 -> Biap bi a b Source # (<$) :: a0 -> Biap bi a b -> Biap bi a a0 Source #
Monad (bi a) => Monad (Biap bi a) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods (>>=) :: Biap bi a a0 -> (a0 -> Biap bi a b) -> Biap bi a b Source # (>>) :: Biap bi a a0 -> Biap bi a b -> Biap bi a b Source # return :: a0 -> Biap bi a a0 Source #
MonadPlus (bi a) => MonadPlus (Biap bi a) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods mzero :: Biap bi a a0 Source # mplus :: Biap bi a a0 -> Biap bi a a0 -> Biap bi a a0 Source #
MonadFail (bi a) => MonadFail (Biap bi a) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods fail :: String -> Biap bi a a0 Source #
Foldable (bi a) => Foldable (Biap bi a) Source # |

Instance details

Defined in Data.Bifunctor.Biap

Methods

fold :: Monoid m => Biap bi a m -> m Source #

foldMap :: Monoid m => (a0 -> m) -> Biap bi a a0 -> m Source #

foldMap' :: Monoid m => (a0 -> m) -> Biap bi a a0 -> m Source #

foldr :: (a0 -> b -> b) -> b -> Biap bi a a0 -> b Source #

foldr' :: (a0 -> b -> b) -> b -> Biap bi a a0 -> b Source #

foldl :: (b -> a0 -> b) -> b -> Biap bi a a0 -> b Source #

foldl' :: (b -> a0 -> b) -> b -> Biap bi a a0 -> b Source #

foldr1 :: (a0 -> a0 -> a0) -> Biap bi a a0 -> a0 Source #

foldl1 :: (a0 -> a0 -> a0) -> Biap bi a a0 -> a0 Source #

toList :: Biap bi a a0 -> [a0] Source #

null :: Biap bi a a0 -> Bool Source #

length :: Biap bi a a0 -> Int Source #

elem :: Eq a0 => a0 -> Biap bi a a0 -> Bool Source #

maximum :: Ord a0 => Biap bi a a0 -> a0 Source #

minimum :: Ord a0 => Biap bi a a0 -> a0 Source #

sum :: Num a0 => Biap bi a a0 -> a0 Source #

product :: Num a0 => Biap bi a a0 -> a0 Source #

Traversable (bi a) => Traversable (Biap bi a) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods traverse :: Applicative f => (a0 -> f b) -> Biap bi a a0 -> f (Biap bi a b) Source # sequenceA :: Applicative f => Biap bi a (f a0) -> f (Biap bi a a0) Source # mapM :: Monad m => (a0 -> m b) -> Biap bi a a0 -> m (Biap bi a b) Source # sequence :: Monad m => Biap bi a (m a0) -> m (Biap bi a a0) Source #
(Biapplicative bi, Monoid a, Monoid b) => Monoid (Biap bi a b) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods mempty :: Biap bi a b Source # mappend :: Biap bi a b -> Biap bi a b -> Biap bi a b Source # mconcat :: [Biap bi a b] -> Biap bi a b Source #
(Biapplicative bi, Semigroup a, Semigroup b) => Semigroup (Biap bi a b) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods (<>) :: Biap bi a b -> Biap bi a b -> Biap bi a b Source # sconcat :: NonEmpty (Biap bi a b) -> Biap bi a b Source # stimes :: Integral b0 => b0 -> Biap bi a b -> Biap bi a b Source #
(Biapplicative bi, Bounded a, Bounded b) => Bounded (Biap bi a b) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods minBound :: Biap bi a b Source # maxBound :: Biap bi a b Source #
Enum (bi a b) => Enum (Biap bi a b) Source # |

Instance details

Defined in Data.Bifunctor.Biap

Methods

succ :: Biap bi a b -> Biap bi a b Source #

pred :: Biap bi a b -> Biap bi a b Source #

toEnum :: Int -> Biap bi a b Source #

fromEnum :: Biap bi a b -> Int Source #

enumFrom :: Biap bi a b -> [Biap bi a b] Source #

enumFromThen :: Biap bi a b -> Biap bi a b -> [Biap bi a b] Source #

enumFromTo :: Biap bi a b -> Biap bi a b -> [Biap bi a b] Source #

enumFromThenTo :: Biap bi a b -> Biap bi a b -> Biap bi a b -> [Biap bi a b] Source #

Generic (Biap bi a b) Source # |

Instance details

Defined in Data.Bifunctor.Biap

Associated Types

type Rep (Biap bi a b) |
Instance details Defined in Data.Bifunctor.Biap type Rep (Biap bi a b) = D1 ('MetaData "Biap" "Data.Bifunctor.Biap" "bifunctors-5.6.2-4kXyA9Yl2Ys9aGae1sUdxu" 'True) (C1 ('MetaCons "Biap" 'PrefixI 'True) (S1 ('MetaSel ('Just "getBiap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (bi a b))))

Methods

from :: Biap bi a b -> Rep (Biap bi a b) x Source #

to :: Rep (Biap bi a b) x -> Biap bi a b Source #

(Biapplicative bi, Num a, Num b) => Num (Biap bi a b) Source # |

Instance details

Defined in Data.Bifunctor.Biap

Methods

(+) :: Biap bi a b -> Biap bi a b -> Biap bi a b Source #

(-) :: Biap bi a b -> Biap bi a b -> Biap bi a b Source #

(*) :: Biap bi a b -> Biap bi a b -> Biap bi a b Source #

negate :: Biap bi a b -> Biap bi a b Source #

abs :: Biap bi a b -> Biap bi a b Source #

signum :: Biap bi a b -> Biap bi a b Source #

fromInteger :: Integer -> Biap bi a b Source #

Read (bi a b) => Read (Biap bi a b) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods readsPrec :: Int -> ReadS (Biap bi a b) Source # readList :: ReadS [Biap bi a b] Source # readPrec :: ReadPrec (Biap bi a b) Source # readListPrec :: ReadPrec [Biap bi a b] Source #
Show (bi a b) => Show (Biap bi a b) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods showsPrec :: Int -> Biap bi a b -> ShowS Source # show :: Biap bi a b -> String Source # showList :: [Biap bi a b] -> ShowS Source #
Eq (bi a b) => Eq (Biap bi a b) Source # |
Instance details Defined in Data.Bifunctor.Biap Methods (==) :: Biap bi a b -> Biap bi a b -> Bool Source # (/=) :: Biap bi a b -> Biap bi a b -> Bool Source #
Ord (bi a b) => Ord (Biap bi a b) Source # |

Instance details

Defined in Data.Bifunctor.Biap

Methods

compare :: Biap bi a b -> Biap bi a b -> Ordering Source #

(<) :: Biap bi a b -> Biap bi a b -> Bool Source #

(<=) :: Biap bi a b -> Biap bi a b -> Bool Source #

(>) :: Biap bi a b -> Biap bi a b -> Bool Source #

(>=) :: Biap bi a b -> Biap bi a b -> Bool Source #

max :: Biap bi a b -> Biap bi a b -> Biap bi a b Source #

min :: Biap bi a b -> Biap bi a b -> Biap bi a b Source #

type Rep1 (Biap bi a :: Type -> Type) Source # |
Instance details Defined in Data.Bifunctor.Biap type Rep1 (Biap bi a :: Type -> Type) = D1 ('MetaData "Biap" "Data.Bifunctor.Biap" "bifunctors-5.6.2-4kXyA9Yl2Ys9aGae1sUdxu" 'True) (C1 ('MetaCons "Biap" 'PrefixI 'True) (S1 ('MetaSel ('Just "getBiap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 (bi a))))
type Rep (Biap bi a b) Source # |
Instance details Defined in Data.Bifunctor.Biap type Rep (Biap bi a b) = D1 ('MetaData "Biap" "Data.Bifunctor.Biap" "bifunctors-5.6.2-4kXyA9Yl2Ys9aGae1sUdxu" 'True) (C1 ('MetaCons "Biap" 'PrefixI 'True) (S1 ('MetaSel ('Just "getBiap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (bi a b))))