{-# LANGUAGE CPP                        #-}
{-# LANGUAGE EmptyDataDecls             #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE DeriveTraversable          #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables        #-}
{-# LANGUAGE TypeFamilies               #-}

#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE DeriveGeneric              #-}
#endif

-- This module uses GND

#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif
#include "bifunctors-common.h"

-----------------------------------------------------------------------------

-- |

-- Copyright   :  (C) 2008-2016 Edward Kmett

-- License     :  BSD-style (see the file LICENSE)

--

-- Maintainer  :  Edward Kmett <ekmett@gmail.com>

-- Stability   :  provisional

-- Portability :  portable

--

----------------------------------------------------------------------------

module Data.Bifunctor.Biap
 ( Biap(..)
 ) where

import Control.Applicative
import Control.Monad
import qualified Control.Monad.Fail as Fail (MonadFail)
import Data.Biapplicative
import Data.Bifoldable
import Data.Bitraversable
import Data.Functor.Classes

#if __GLASGOW_HASKELL__ >= 702
import GHC.Generics
#endif

#if !(MIN_VERSION_base(4,8,0))
import Data.Foldable
import Data.Monoid
import Data.Traversable
#endif

import qualified Data.Semigroup as S

-- | 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 'Data.Monoid.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

-- @

--

newtype Biap bi a b = Biap { forall (bi :: * -> * -> *) a b. Biap bi a b -> bi a b
getBiap :: bi a b }
 deriving ( Biap bi a b -> Biap bi a b -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (bi :: * -> * -> *) a b.
Eq (bi a b) =>
Biap bi a b -> Biap bi a b -> Bool
/= :: Biap bi a b -> Biap bi a b -> Bool
$c/= :: forall (bi :: * -> * -> *) a b.
Eq (bi a b) =>
Biap bi a b -> Biap bi a b -> Bool
== :: Biap bi a b -> Biap bi a b -> Bool
$c== :: forall (bi :: * -> * -> *) a b.
Eq (bi a b) =>
Biap bi a b -> Biap bi a b -> Bool
Eq
          , Biap bi a b -> Biap bi a b -> Bool
Biap bi a b -> Biap bi a b -> Ordering
Biap bi a b -> Biap bi a b -> Biap bi a b
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {bi :: * -> * -> *} {a} {b}.
Ord (bi a b) =>
Eq (Biap bi a b)
forall (bi :: * -> * -> *) a b.
Ord (bi a b) =>
Biap bi a b -> Biap bi a b -> Bool
forall (bi :: * -> * -> *) a b.
Ord (bi a b) =>
Biap bi a b -> Biap bi a b -> Ordering
forall (bi :: * -> * -> *) a b.
Ord (bi a b) =>
Biap bi a b -> Biap bi a b -> Biap bi a b
min :: Biap bi a b -> Biap bi a b -> Biap bi a b
$cmin :: forall (bi :: * -> * -> *) a b.
Ord (bi a b) =>
Biap bi a b -> Biap bi a b -> Biap bi a b
max :: Biap bi a b -> Biap bi a b -> Biap bi a b
$cmax :: forall (bi :: * -> * -> *) a b.
Ord (bi a b) =>
Biap bi a b -> Biap bi a b -> Biap bi a b
>= :: Biap bi a b -> Biap bi a b -> Bool
$c>= :: forall (bi :: * -> * -> *) a b.
Ord (bi a b) =>
Biap bi a b -> Biap bi a b -> Bool
> :: Biap bi a b -> Biap bi a b -> Bool
$c> :: forall (bi :: * -> * -> *) a b.
Ord (bi a b) =>
Biap bi a b -> Biap bi a b -> Bool
<= :: Biap bi a b -> Biap bi a b -> Bool
$c<= :: forall (bi :: * -> * -> *) a b.
Ord (bi a b) =>
Biap bi a b -> Biap bi a b -> Bool
< :: Biap bi a b -> Biap bi a b -> Bool
$c< :: forall (bi :: * -> * -> *) a b.
Ord (bi a b) =>
Biap bi a b -> Biap bi a b -> Bool
compare :: Biap bi a b -> Biap bi a b -> Ordering
$ccompare :: forall (bi :: * -> * -> *) a b.
Ord (bi a b) =>
Biap bi a b -> Biap bi a b -> Ordering
Ord
          , Int -> Biap bi a b -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (bi :: * -> * -> *) a b.
Show (bi a b) =>
Int -> Biap bi a b -> ShowS
forall (bi :: * -> * -> *) a b.
Show (bi a b) =>
[Biap bi a b] -> ShowS
forall (bi :: * -> * -> *) a b.
Show (bi a b) =>
Biap bi a b -> String
showList :: [Biap bi a b] -> ShowS
$cshowList :: forall (bi :: * -> * -> *) a b.
Show (bi a b) =>
[Biap bi a b] -> ShowS
show :: Biap bi a b -> String
$cshow :: forall (bi :: * -> * -> *) a b.
Show (bi a b) =>
Biap bi a b -> String
showsPrec :: Int -> Biap bi a b -> ShowS
$cshowsPrec :: forall (bi :: * -> * -> *) a b.
Show (bi a b) =>
Int -> Biap bi a b -> ShowS
Show
          , ReadPrec [Biap bi a b]
ReadPrec (Biap bi a b)
ReadS [Biap bi a b]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall (bi :: * -> * -> *) a b.
Read (bi a b) =>
ReadPrec [Biap bi a b]
forall (bi :: * -> * -> *) a b.
Read (bi a b) =>
ReadPrec (Biap bi a b)
forall (bi :: * -> * -> *) a b.
Read (bi a b) =>
Int -> ReadS (Biap bi a b)
forall (bi :: * -> * -> *) a b.
Read (bi a b) =>
ReadS [Biap bi a b]
readListPrec :: ReadPrec [Biap bi a b]
$creadListPrec :: forall (bi :: * -> * -> *) a b.
Read (bi a b) =>
ReadPrec [Biap bi a b]
readPrec :: ReadPrec (Biap bi a b)
$creadPrec :: forall (bi :: * -> * -> *) a b.
Read (bi a b) =>
ReadPrec (Biap bi a b)
readList :: ReadS [Biap bi a b]
$creadList :: forall (bi :: * -> * -> *) a b.
Read (bi a b) =>
ReadS [Biap bi a b]
readsPrec :: Int -> ReadS (Biap bi a b)
$creadsPrec :: forall (bi :: * -> * -> *) a b.
Read (bi a b) =>
Int -> ReadS (Biap bi a b)
Read
          , Int -> Biap bi a b
Biap bi a b -> Int
Biap bi a b -> [Biap bi a b]
Biap bi a b -> Biap bi a b
Biap bi a b -> Biap bi a b -> [Biap bi a b]
Biap bi a b -> Biap bi a b -> Biap bi a b -> [Biap bi a b]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
forall (bi :: * -> * -> *) a b. Enum (bi a b) => Int -> Biap bi a b
forall (bi :: * -> * -> *) a b. Enum (bi a b) => Biap bi a b -> Int
forall (bi :: * -> * -> *) a b.
Enum (bi a b) =>
Biap bi a b -> [Biap bi a b]
forall (bi :: * -> * -> *) a b.
Enum (bi a b) =>
Biap bi a b -> Biap bi a b
forall (bi :: * -> * -> *) a b.
Enum (bi a b) =>
Biap bi a b -> Biap bi a b -> [Biap bi a b]
forall (bi :: * -> * -> *) a b.
Enum (bi a b) =>
Biap bi a b -> Biap bi a b -> Biap bi a b -> [Biap bi a b]
enumFromThenTo :: Biap bi a b -> Biap bi a b -> Biap bi a b -> [Biap bi a b]
$cenumFromThenTo :: forall (bi :: * -> * -> *) a b.
Enum (bi a b) =>
Biap bi a b -> Biap bi a b -> Biap bi a b -> [Biap bi a b]
enumFromTo :: Biap bi a b -> Biap bi a b -> [Biap bi a b]
$cenumFromTo :: forall (bi :: * -> * -> *) a b.
Enum (bi a b) =>
Biap bi a b -> Biap bi a b -> [Biap bi a b]
enumFromThen :: Biap bi a b -> Biap bi a b -> [Biap bi a b]
$cenumFromThen :: forall (bi :: * -> * -> *) a b.
Enum (bi a b) =>
Biap bi a b -> Biap bi a b -> [Biap bi a b]
enumFrom :: Biap bi a b -> [Biap bi a b]
$cenumFrom :: forall (bi :: * -> * -> *) a b.
Enum (bi a b) =>
Biap bi a b -> [Biap bi a b]
fromEnum :: Biap bi a b -> Int
$cfromEnum :: forall (bi :: * -> * -> *) a b. Enum (bi a b) => Biap bi a b -> Int
toEnum :: Int -> Biap bi a b
$ctoEnum :: forall (bi :: * -> * -> *) a b. Enum (bi a b) => Int -> Biap bi a b
pred :: Biap bi a b -> Biap bi a b
$cpred :: forall (bi :: * -> * -> *) a b.
Enum (bi a b) =>
Biap bi a b -> Biap bi a b
succ :: Biap bi a b -> Biap bi a b
$csucc :: forall (bi :: * -> * -> *) a b.
Enum (bi a b) =>
Biap bi a b -> Biap bi a b
Enum
          , forall a b. a -> Biap bi a b -> Biap bi a a
forall a b. (a -> b) -> Biap bi a a -> Biap bi a b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
forall (bi :: * -> * -> *) a a b.
Functor (bi a) =>
a -> Biap bi a b -> Biap bi a a
forall (bi :: * -> * -> *) a a b.
Functor (bi a) =>
(a -> b) -> Biap bi a a -> Biap bi a b
<$ :: forall a b. a -> Biap bi a b -> Biap bi a a
$c<$ :: forall (bi :: * -> * -> *) a a b.
Functor (bi a) =>
a -> Biap bi a b -> Biap bi a a
fmap :: forall a b. (a -> b) -> Biap bi a a -> Biap bi a b
$cfmap :: forall (bi :: * -> * -> *) a a b.
Functor (bi a) =>
(a -> b) -> Biap bi a a -> Biap bi a b
Functor
          , forall a. Eq a => a -> Biap bi a a -> Bool
forall a. Num a => Biap bi a a -> a
forall a. Ord a => Biap bi a a -> a
forall m. Monoid m => Biap bi a m -> m
forall a. Biap bi a a -> Bool
forall a. Biap bi a a -> Int
forall a. Biap bi a a -> [a]
forall a. (a -> a -> a) -> Biap bi a a -> a
forall m a. Monoid m => (a -> m) -> Biap bi a a -> m
forall b a. (b -> a -> b) -> b -> Biap bi a a -> b
forall a b. (a -> b -> b) -> b -> Biap bi a a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
forall (bi :: * -> * -> *) a a.
(Foldable (bi a), Eq a) =>
a -> Biap bi a a -> Bool
forall (bi :: * -> * -> *) a a.
(Foldable (bi a), Num a) =>
Biap bi a a -> a
forall (bi :: * -> * -> *) a a.
(Foldable (bi a), Ord a) =>
Biap bi a a -> a
forall (bi :: * -> * -> *) a m.
(Foldable (bi a), Monoid m) =>
Biap bi a m -> m
forall (bi :: * -> * -> *) a a.
Foldable (bi a) =>
Biap bi a a -> Bool
forall (bi :: * -> * -> *) a a.
Foldable (bi a) =>
Biap bi a a -> Int
forall (bi :: * -> * -> *) a a.
Foldable (bi a) =>
Biap bi a a -> [a]
forall (bi :: * -> * -> *) a a.
Foldable (bi a) =>
(a -> a -> a) -> Biap bi a a -> a
forall (bi :: * -> * -> *) a m a.
(Foldable (bi a), Monoid m) =>
(a -> m) -> Biap bi a a -> m
forall (bi :: * -> * -> *) a b a.
Foldable (bi a) =>
(b -> a -> b) -> b -> Biap bi a a -> b
forall (bi :: * -> * -> *) a a b.
Foldable (bi a) =>
(a -> b -> b) -> b -> Biap bi a a -> b
product :: forall a. Num a => Biap bi a a -> a
$cproduct :: forall (bi :: * -> * -> *) a a.
(Foldable (bi a), Num a) =>
Biap bi a a -> a
sum :: forall a. Num a => Biap bi a a -> a
$csum :: forall (bi :: * -> * -> *) a a.
(Foldable (bi a), Num a) =>
Biap bi a a -> a
minimum :: forall a. Ord a => Biap bi a a -> a
$cminimum :: forall (bi :: * -> * -> *) a a.
(Foldable (bi a), Ord a) =>
Biap bi a a -> a
maximum :: forall a. Ord a => Biap bi a a -> a
$cmaximum :: forall (bi :: * -> * -> *) a a.
(Foldable (bi a), Ord a) =>
Biap bi a a -> a
elem :: forall a. Eq a => a -> Biap bi a a -> Bool
$celem :: forall (bi :: * -> * -> *) a a.
(Foldable (bi a), Eq a) =>
a -> Biap bi a a -> Bool
length :: forall a. Biap bi a a -> Int
$clength :: forall (bi :: * -> * -> *) a a.
Foldable (bi a) =>
Biap bi a a -> Int
null :: forall a. Biap bi a a -> Bool
$cnull :: forall (bi :: * -> * -> *) a a.
Foldable (bi a) =>
Biap bi a a -> Bool
toList :: forall a. Biap bi a a -> [a]
$ctoList :: forall (bi :: * -> * -> *) a a.
Foldable (bi a) =>
Biap bi a a -> [a]
foldl1 :: forall a. (a -> a -> a) -> Biap bi a a -> a
$cfoldl1 :: forall (bi :: * -> * -> *) a a.
Foldable (bi a) =>
(a -> a -> a) -> Biap bi a a -> a
foldr1 :: forall a. (a -> a -> a) -> Biap bi a a -> a
$cfoldr1 :: forall (bi :: * -> * -> *) a a.
Foldable (bi a) =>
(a -> a -> a) -> Biap bi a a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> Biap bi a a -> b
$cfoldl' :: forall (bi :: * -> * -> *) a b a.
Foldable (bi a) =>
(b -> a -> b) -> b -> Biap bi a a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Biap bi a a -> b
$cfoldl :: forall (bi :: * -> * -> *) a b a.
Foldable (bi a) =>
(b -> a -> b) -> b -> Biap bi a a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Biap bi a a -> b
$cfoldr' :: forall (bi :: * -> * -> *) a a b.
Foldable (bi a) =>
(a -> b -> b) -> b -> Biap bi a a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Biap bi a a -> b
$cfoldr :: forall (bi :: * -> * -> *) a a b.
Foldable (bi a) =>
(a -> b -> b) -> b -> Biap bi a a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> Biap bi a a -> m
$cfoldMap' :: forall (bi :: * -> * -> *) a m a.
(Foldable (bi a), Monoid m) =>
(a -> m) -> Biap bi a a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Biap bi a a -> m
$cfoldMap :: forall (bi :: * -> * -> *) a m a.
(Foldable (bi a), Monoid m) =>
(a -> m) -> Biap bi a a -> m
fold :: forall m. Monoid m => Biap bi a m -> m
$cfold :: forall (bi :: * -> * -> *) a m.
(Foldable (bi a), Monoid m) =>
Biap bi a m -> m
Foldable
          , forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Biap bi a a -> f (Biap bi a b)
forall {bi :: * -> * -> *} {a}.
Traversable (bi a) =>
Functor (Biap bi a)
forall {bi :: * -> * -> *} {a}.
Traversable (bi a) =>
Foldable (Biap bi a)
forall (bi :: * -> * -> *) a (m :: * -> *) a.
(Traversable (bi a), Monad m) =>
Biap bi a (m a) -> m (Biap bi a a)
forall (bi :: * -> * -> *) a (f :: * -> *) a.
(Traversable (bi a), Applicative f) =>
Biap bi a (f a) -> f (Biap bi a a)
forall (bi :: * -> * -> *) a (m :: * -> *) a b.
(Traversable (bi a), Monad m) =>
(a -> m b) -> Biap bi a a -> m (Biap bi a b)
forall (bi :: * -> * -> *) a (f :: * -> *) a b.
(Traversable (bi a), Applicative f) =>
(a -> f b) -> Biap bi a a -> f (Biap bi a b)
sequence :: forall (m :: * -> *) a.
Monad m =>
Biap bi a (m a) -> m (Biap bi a a)
$csequence :: forall (bi :: * -> * -> *) a (m :: * -> *) a.
(Traversable (bi a), Monad m) =>
Biap bi a (m a) -> m (Biap bi a a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Biap bi a a -> m (Biap bi a b)
$cmapM :: forall (bi :: * -> * -> *) a (m :: * -> *) a b.
(Traversable (bi a), Monad m) =>
(a -> m b) -> Biap bi a a -> m (Biap bi a b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
Biap bi a (f a) -> f (Biap bi a a)
$csequenceA :: forall (bi :: * -> * -> *) a (f :: * -> *) a.
(Traversable (bi a), Applicative f) =>
Biap bi a (f a) -> f (Biap bi a a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Biap bi a a -> f (Biap bi a b)
$ctraverse :: forall (bi :: * -> * -> *) a (f :: * -> *) a b.
(Traversable (bi a), Applicative f) =>
(a -> f b) -> Biap bi a a -> f (Biap bi a b)
Traversable
          , forall a. Biap bi a a
forall a. Biap bi a a -> Biap bi a [a]
forall a. Biap bi a a -> Biap bi a a -> Biap bi a a
forall (f :: * -> *).
Applicative f
-> (forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
forall {bi :: * -> * -> *} {a}.
Alternative (bi a) =>
Applicative (Biap bi a)
forall (bi :: * -> * -> *) a a. Alternative (bi a) => Biap bi a a
forall (bi :: * -> * -> *) a a.
Alternative (bi a) =>
Biap bi a a -> Biap bi a [a]
forall (bi :: * -> * -> *) a a.
Alternative (bi a) =>
Biap bi a a -> Biap bi a a -> Biap bi a a
many :: forall a. Biap bi a a -> Biap bi a [a]
$cmany :: forall (bi :: * -> * -> *) a a.
Alternative (bi a) =>
Biap bi a a -> Biap bi a [a]
some :: forall a. Biap bi a a -> Biap bi a [a]
$csome :: forall (bi :: * -> * -> *) a a.
Alternative (bi a) =>
Biap bi a a -> Biap bi a [a]
<|> :: forall a. Biap bi a a -> Biap bi a a -> Biap bi a a
$c<|> :: forall (bi :: * -> * -> *) a a.
Alternative (bi a) =>
Biap bi a a -> Biap bi a a -> Biap bi a a
empty :: forall a. Biap bi a a
$cempty :: forall (bi :: * -> * -> *) a a. Alternative (bi a) => Biap bi a a
Alternative
          , forall a. a -> Biap bi a a
forall a b. Biap bi a a -> Biap bi a b -> Biap bi a a
forall a b. Biap bi a a -> Biap bi a b -> Biap bi a b
forall a b. Biap bi a (a -> b) -> Biap bi a a -> Biap bi a b
forall a b c.
(a -> b -> c) -> Biap bi a a -> Biap bi a b -> Biap bi a c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
forall {bi :: * -> * -> *} {a}.
Applicative (bi a) =>
Functor (Biap bi a)
forall (bi :: * -> * -> *) a a.
Applicative (bi a) =>
a -> Biap bi a a
forall (bi :: * -> * -> *) a a b.
Applicative (bi a) =>
Biap bi a a -> Biap bi a b -> Biap bi a a
forall (bi :: * -> * -> *) a a b.
Applicative (bi a) =>
Biap bi a a -> Biap bi a b -> Biap bi a b
forall (bi :: * -> * -> *) a a b.
Applicative (bi a) =>
Biap bi a (a -> b) -> Biap bi a a -> Biap bi a b
forall (bi :: * -> * -> *) a a b c.
Applicative (bi a) =>
(a -> b -> c) -> Biap bi a a -> Biap bi a b -> Biap bi a c
<* :: forall a b. Biap bi a a -> Biap bi a b -> Biap bi a a
$c<* :: forall (bi :: * -> * -> *) a a b.
Applicative (bi a) =>
Biap bi a a -> Biap bi a b -> Biap bi a a
*> :: forall a b. Biap bi a a -> Biap bi a b -> Biap bi a b
$c*> :: forall (bi :: * -> * -> *) a a b.
Applicative (bi a) =>
Biap bi a a -> Biap bi a b -> Biap bi a b
liftA2 :: forall a b c.
(a -> b -> c) -> Biap bi a a -> Biap bi a b -> Biap bi a c
$cliftA2 :: forall (bi :: * -> * -> *) a a b c.
Applicative (bi a) =>
(a -> b -> c) -> Biap bi a a -> Biap bi a b -> Biap bi a c
<*> :: forall a b. Biap bi a (a -> b) -> Biap bi a a -> Biap bi a b
$c<*> :: forall (bi :: * -> * -> *) a a b.
Applicative (bi a) =>
Biap bi a (a -> b) -> Biap bi a a -> Biap bi a b
pure :: forall a. a -> Biap bi a a
$cpure :: forall (bi :: * -> * -> *) a a.
Applicative (bi a) =>
a -> Biap bi a a
Applicative
#if __GLASGOW_HASKELL__ >= 702
          , forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (bi :: * -> * -> *) a b x.
Rep (Biap bi a b) x -> Biap bi a b
forall (bi :: * -> * -> *) a b x.
Biap bi a b -> Rep (Biap bi a b) x
$cto :: forall (bi :: * -> * -> *) a b x.
Rep (Biap bi a b) x -> Biap bi a b
$cfrom :: forall (bi :: * -> * -> *) a b x.
Biap bi a b -> Rep (Biap bi a b) x
Generic
#endif
#if __GLASGOW_HASKELL__ >= 706
          , forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
forall (bi :: * -> * -> *) a a. Rep1 (Biap bi a) a -> Biap bi a a
forall (bi :: * -> * -> *) a a. Biap bi a a -> Rep1 (Biap bi a) a
$cto1 :: forall (bi :: * -> * -> *) a a. Rep1 (Biap bi a) a -> Biap bi a a
$cfrom1 :: forall (bi :: * -> * -> *) a a. Biap bi a a -> Rep1 (Biap bi a) a
Generic1
#endif
          , forall a. a -> Biap bi a a
forall a b. Biap bi a a -> Biap bi a b -> Biap bi a b
forall a b. Biap bi a a -> (a -> Biap bi a b) -> Biap bi a b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
forall {bi :: * -> * -> *} {a}.
Monad (bi a) =>
Applicative (Biap bi a)
forall (bi :: * -> * -> *) a a. Monad (bi a) => a -> Biap bi a a
forall (bi :: * -> * -> *) a a b.
Monad (bi a) =>
Biap bi a a -> Biap bi a b -> Biap bi a b
forall (bi :: * -> * -> *) a a b.
Monad (bi a) =>
Biap bi a a -> (a -> Biap bi a b) -> Biap bi a b
return :: forall a. a -> Biap bi a a
$creturn :: forall (bi :: * -> * -> *) a a. Monad (bi a) => a -> Biap bi a a
>> :: forall a b. Biap bi a a -> Biap bi a b -> Biap bi a b
$c>> :: forall (bi :: * -> * -> *) a a b.
Monad (bi a) =>
Biap bi a a -> Biap bi a b -> Biap bi a b
>>= :: forall a b. Biap bi a a -> (a -> Biap bi a b) -> Biap bi a b
$c>>= :: forall (bi :: * -> * -> *) a a b.
Monad (bi a) =>
Biap bi a a -> (a -> Biap bi a b) -> Biap bi a b
Monad
          , forall a. String -> Biap bi a a
forall (m :: * -> *).
Monad m -> (forall a. String -> m a) -> MonadFail m
forall {bi :: * -> * -> *} {a}.
MonadFail (bi a) =>
Monad (Biap bi a)
forall (bi :: * -> * -> *) a a.
MonadFail (bi a) =>
String -> Biap bi a a
fail :: forall a. String -> Biap bi a a
$cfail :: forall (bi :: * -> * -> *) a a.
MonadFail (bi a) =>
String -> Biap bi a a
Fail.MonadFail
          , forall a. Biap bi a a
forall a. Biap bi a a -> Biap bi a a -> Biap bi a a
forall (m :: * -> *).
Alternative m
-> Monad m
-> (forall a. m a)
-> (forall a. m a -> m a -> m a)
-> MonadPlus m
forall {bi :: * -> * -> *} {a}.
MonadPlus (bi a) =>
Monad (Biap bi a)
forall {bi :: * -> * -> *} {a}.
MonadPlus (bi a) =>
Alternative (Biap bi a)
forall (bi :: * -> * -> *) a a. MonadPlus (bi a) => Biap bi a a
forall (bi :: * -> * -> *) a a.
MonadPlus (bi a) =>
Biap bi a a -> Biap bi a a -> Biap bi a a
mplus :: forall a. Biap bi a a -> Biap bi a a -> Biap bi a a
$cmplus :: forall (bi :: * -> * -> *) a a.
MonadPlus (bi a) =>
Biap bi a a -> Biap bi a a -> Biap bi a a
mzero :: forall a. Biap bi a a
$cmzero :: forall (bi :: * -> * -> *) a a. MonadPlus (bi a) => Biap bi a a
MonadPlus
          , forall a b. (a -> b -> Bool) -> Biap bi a a -> Biap bi a b -> Bool
forall (f :: * -> *).
(forall a b. (a -> b -> Bool) -> f a -> f b -> Bool) -> Eq1 f
forall (bi :: * -> * -> *) a a b.
Eq1 (bi a) =>
(a -> b -> Bool) -> Biap bi a a -> Biap bi a b -> Bool
liftEq :: forall a b. (a -> b -> Bool) -> Biap bi a a -> Biap bi a b -> Bool
$cliftEq :: forall (bi :: * -> * -> *) a a b.
Eq1 (bi a) =>
(a -> b -> Bool) -> Biap bi a a -> Biap bi a b -> Bool
Eq1
          , forall a b.
(a -> b -> Ordering) -> Biap bi a a -> Biap bi a b -> Ordering
forall (f :: * -> *).
Eq1 f
-> (forall a b. (a -> b -> Ordering) -> f a -> f b -> Ordering)
-> Ord1 f
forall {bi :: * -> * -> *} {a}. Ord1 (bi a) => Eq1 (Biap bi a)
forall (bi :: * -> * -> *) a a b.
Ord1 (bi a) =>
(a -> b -> Ordering) -> Biap bi a a -> Biap bi a b -> Ordering
liftCompare :: forall a b.
(a -> b -> Ordering) -> Biap bi a a -> Biap bi a b -> Ordering
$cliftCompare :: forall (bi :: * -> * -> *) a a b.
Ord1 (bi a) =>
(a -> b -> Ordering) -> Biap bi a a -> Biap bi a b -> Ordering
Ord1

          , forall a b c. (a -> b) -> Biap bi a c -> Biap bi b c
forall b c a. (b -> c) -> Biap bi a b -> Biap bi a c
forall a b c d. (a -> b) -> (c -> d) -> Biap bi a c -> Biap bi b d
forall (bi :: * -> * -> *) a b c.
Bifunctor bi =>
(a -> b) -> Biap bi a c -> Biap bi b c
forall (bi :: * -> * -> *) b c a.
Bifunctor bi =>
(b -> c) -> Biap bi a b -> Biap bi a c
forall (bi :: * -> * -> *) a b c d.
Bifunctor bi =>
(a -> b) -> (c -> d) -> Biap bi a c -> Biap bi b d
forall (p :: * -> * -> *).
(forall a b c d. (a -> b) -> (c -> d) -> p a c -> p b d)
-> (forall a b c. (a -> b) -> p a c -> p b c)
-> (forall b c a. (b -> c) -> p a b -> p a c)
-> Bifunctor p
second :: forall b c a. (b -> c) -> Biap bi a b -> Biap bi a c
$csecond :: forall (bi :: * -> * -> *) b c a.
Bifunctor bi =>
(b -> c) -> Biap bi a b -> Biap bi a c
first :: forall a b c. (a -> b) -> Biap bi a c -> Biap bi b c
$cfirst :: forall (bi :: * -> * -> *) a b c.
Bifunctor bi =>
(a -> b) -> Biap bi a c -> Biap bi b c
bimap :: forall a b c d. (a -> b) -> (c -> d) -> Biap bi a c -> Biap bi b d
$cbimap :: forall (bi :: * -> * -> *) a b c d.
Bifunctor bi =>
(a -> b) -> (c -> d) -> Biap bi a c -> Biap bi b d
Bifunctor
          , forall a b. a -> b -> Biap bi a b
forall a b c d. Biap bi a b -> Biap bi c d -> Biap bi a b
forall a b c d. Biap bi a b -> Biap bi c d -> Biap bi c d
forall a b c d.
Biap bi (a -> b) (c -> d) -> Biap bi a c -> Biap bi b d
forall a b c d e f.
(a -> b -> c)
-> (d -> e -> f) -> Biap bi a d -> Biap bi b e -> Biap bi c f
forall (p :: * -> * -> *).
Bifunctor p
-> (forall a b. a -> b -> p a b)
-> (forall a b c d. p (a -> b) (c -> d) -> p a c -> p b d)
-> (forall a b c d e f.
    (a -> b -> c) -> (d -> e -> f) -> p a d -> p b e -> p c f)
-> (forall a b c d. p a b -> p c d -> p c d)
-> (forall a b c d. p a b -> p c d -> p a b)
-> Biapplicative p
forall {bi :: * -> * -> *}. Biapplicative bi => Bifunctor (Biap bi)
forall (bi :: * -> * -> *) a b.
Biapplicative bi =>
a -> b -> Biap bi a b
forall (bi :: * -> * -> *) a b c d.
Biapplicative bi =>
Biap bi a b -> Biap bi c d -> Biap bi a b
forall (bi :: * -> * -> *) a b c d.
Biapplicative bi =>
Biap bi a b -> Biap bi c d -> Biap bi c d
forall (bi :: * -> * -> *) a b c d.
Biapplicative bi =>
Biap bi (a -> b) (c -> d) -> Biap bi a c -> Biap bi b d
forall (bi :: * -> * -> *) a b c d e f.
Biapplicative bi =>
(a -> b -> c)
-> (d -> e -> f) -> Biap bi a d -> Biap bi b e -> Biap bi c f
<<* :: forall a b c d. Biap bi a b -> Biap bi c d -> Biap bi a b
$c<<* :: forall (bi :: * -> * -> *) a b c d.
Biapplicative bi =>
Biap bi a b -> Biap bi c d -> Biap bi a b
*>> :: forall a b c d. Biap bi a b -> Biap bi c d -> Biap bi c d
$c*>> :: forall (bi :: * -> * -> *) a b c d.
Biapplicative bi =>
Biap bi a b -> Biap bi c d -> Biap bi c d
biliftA2 :: forall a b c d e f.
(a -> b -> c)
-> (d -> e -> f) -> Biap bi a d -> Biap bi b e -> Biap bi c f
$cbiliftA2 :: forall (bi :: * -> * -> *) a b c d e f.
Biapplicative bi =>
(a -> b -> c)
-> (d -> e -> f) -> Biap bi a d -> Biap bi b e -> Biap bi c f
<<*>> :: forall a b c d.
Biap bi (a -> b) (c -> d) -> Biap bi a c -> Biap bi b d
$c<<*>> :: forall (bi :: * -> * -> *) a b c d.
Biapplicative bi =>
Biap bi (a -> b) (c -> d) -> Biap bi a c -> Biap bi b d
bipure :: forall a b. a -> b -> Biap bi a b
$cbipure :: forall (bi :: * -> * -> *) a b.
Biapplicative bi =>
a -> b -> Biap bi a b
Biapplicative
          , forall m. Monoid m => Biap bi m m -> m
forall m a b. Monoid m => (a -> m) -> (b -> m) -> Biap bi a b -> m
forall c a b.
(c -> a -> c) -> (c -> b -> c) -> c -> Biap bi a b -> c
forall a c b.
(a -> c -> c) -> (b -> c -> c) -> c -> Biap bi a b -> c
forall (bi :: * -> * -> *) m.
(Bifoldable bi, Monoid m) =>
Biap bi m m -> m
forall (bi :: * -> * -> *) m a b.
(Bifoldable bi, Monoid m) =>
(a -> m) -> (b -> m) -> Biap bi a b -> m
forall (bi :: * -> * -> *) c a b.
Bifoldable bi =>
(c -> a -> c) -> (c -> b -> c) -> c -> Biap bi a b -> c
forall (bi :: * -> * -> *) a c b.
Bifoldable bi =>
(a -> c -> c) -> (b -> c -> c) -> c -> Biap bi a b -> c
forall (p :: * -> * -> *).
(forall m. Monoid m => p m m -> m)
-> (forall m a b. Monoid m => (a -> m) -> (b -> m) -> p a b -> m)
-> (forall a c b.
    (a -> c -> c) -> (b -> c -> c) -> c -> p a b -> c)
-> (forall c a b.
    (c -> a -> c) -> (c -> b -> c) -> c -> p a b -> c)
-> Bifoldable p
bifoldl :: forall c a b.
(c -> a -> c) -> (c -> b -> c) -> c -> Biap bi a b -> c
$cbifoldl :: forall (bi :: * -> * -> *) c a b.
Bifoldable bi =>
(c -> a -> c) -> (c -> b -> c) -> c -> Biap bi a b -> c
bifoldr :: forall a c b.
(a -> c -> c) -> (b -> c -> c) -> c -> Biap bi a b -> c
$cbifoldr :: forall (bi :: * -> * -> *) a c b.
Bifoldable bi =>
(a -> c -> c) -> (b -> c -> c) -> c -> Biap bi a b -> c
bifoldMap :: forall m a b. Monoid m => (a -> m) -> (b -> m) -> Biap bi a b -> m
$cbifoldMap :: forall (bi :: * -> * -> *) m a b.
(Bifoldable bi, Monoid m) =>
(a -> m) -> (b -> m) -> Biap bi a b -> m
bifold :: forall m. Monoid m => Biap bi m m -> m
$cbifold :: forall (bi :: * -> * -> *) m.
(Bifoldable bi, Monoid m) =>
Biap bi m m -> m
Bifoldable
#if LIFTED_FUNCTOR_CLASSES
          , forall a b c d.
(a -> b -> Bool)
-> (c -> d -> Bool) -> Biap bi a c -> Biap bi b d -> Bool
forall (bi :: * -> * -> *) a b c d.
Eq2 bi =>
(a -> b -> Bool)
-> (c -> d -> Bool) -> Biap bi a c -> Biap bi b d -> Bool
forall (f :: * -> * -> *).
(forall a b c d.
 (a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool)
-> Eq2 f
liftEq2 :: forall a b c d.
(a -> b -> Bool)
-> (c -> d -> Bool) -> Biap bi a c -> Biap bi b d -> Bool
$cliftEq2 :: forall (bi :: * -> * -> *) a b c d.
Eq2 bi =>
(a -> b -> Bool)
-> (c -> d -> Bool) -> Biap bi a c -> Biap bi b d -> Bool
Eq2
          , forall a b c d.
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> Biap bi a c -> Biap bi b d -> Ordering
forall {bi :: * -> * -> *}. Ord2 bi => Eq2 (Biap bi)
forall (bi :: * -> * -> *) a b c d.
Ord2 bi =>
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> Biap bi a c -> Biap bi b d -> Ordering
forall (f :: * -> * -> *).
Eq2 f
-> (forall a b c d.
    (a -> b -> Ordering)
    -> (c -> d -> Ordering) -> f a c -> f b d -> Ordering)
-> Ord2 f
liftCompare2 :: forall a b c d.
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> Biap bi a c -> Biap bi b d -> Ordering
$cliftCompare2 :: forall (bi :: * -> * -> *) a b c d.
Ord2 bi =>
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> Biap bi a c -> Biap bi b d -> Ordering
Ord2
#endif
          )

instance Bitraversable bi => Bitraversable (Biap bi) where
 bitraverse :: forall (f :: * -> *) a c b d.
Applicative f =>
(a -> f c) -> (b -> f d) -> Biap bi a b -> f (Biap bi c d)
bitraverse a -> f c
f b -> f d
g (Biap bi a b
as) = forall (bi :: * -> * -> *) a b. bi a b -> Biap bi a b
Biap forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> * -> *) (f :: * -> *) a c b d.
(Bitraversable t, Applicative f) =>
(a -> f c) -> (b -> f d) -> t a b -> f (t c d)
bitraverse a -> f c
f b -> f d
g bi a b
as

instance (Biapplicative bi, S.Semigroup a, S.Semigroup b) => S.Semigroup (Biap bi a b) where
  <> :: Biap bi a b -> Biap bi a b -> Biap bi a b
(<>) = forall (p :: * -> * -> *) a b c d e f.
Biapplicative p =>
(a -> b -> c) -> (d -> e -> f) -> p a d -> p b e -> p c f
biliftA2 forall a. Semigroup a => a -> a -> a
(S.<>) forall a. Semigroup a => a -> a -> a
(S.<>)

instance (Biapplicative bi, Monoid a, Monoid b) => Monoid (Biap bi a b) where
  mempty :: Biap bi a b
mempty = forall (p :: * -> * -> *) a b. Biapplicative p => a -> b -> p a b
bipure forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty
#if !(MIN_VERSION_base(4,11,0))
  mappend = biliftA2 mappend mappend
#endif

instance (Biapplicative bi, Bounded a, Bounded b) => Bounded (Biap bi a b) where
  minBound :: Biap bi a b
minBound = forall (p :: * -> * -> *) a b. Biapplicative p => a -> b -> p a b
bipure forall a. Bounded a => a
minBound forall a. Bounded a => a
minBound
  maxBound :: Biap bi a b
maxBound = forall (p :: * -> * -> *) a b. Biapplicative p => a -> b -> p a b
bipure forall a. Bounded a => a
maxBound forall a. Bounded a => a
maxBound

instance ( Biapplicative bi, Num a, Num b
#if !(MIN_VERSION_base(4,5,0))
           -- Old versions of Num have Eq and Show as superclasses. Sigh.

         , Eq (bi a b), Show (bi a b)
#endif
         ) => Num (Biap bi a b) where
  + :: Biap bi a b -> Biap bi a b -> Biap bi a b
(+) = forall (p :: * -> * -> *) a b c d e f.
Biapplicative p =>
(a -> b -> c) -> (d -> e -> f) -> p a d -> p b e -> p c f
biliftA2 forall a. Num a => a -> a -> a
(+) forall a. Num a => a -> a -> a
(+)
  * :: Biap bi a b -> Biap bi a b -> Biap bi a b
(*) = forall (p :: * -> * -> *) a b c d e f.
Biapplicative p =>
(a -> b -> c) -> (d -> e -> f) -> p a d -> p b e -> p c f
biliftA2 forall a. Num a => a -> a -> a
(*) forall a. Num a => a -> a -> a
(*)

  negate :: Biap bi a b -> Biap bi a b
negate = forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap forall a. Num a => a -> a
negate forall a. Num a => a -> a
negate
  abs :: Biap bi a b -> Biap bi a b
abs    = forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap forall a. Num a => a -> a
abs    forall a. Num a => a -> a
abs
  signum :: Biap bi a b -> Biap bi a b
signum = forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap forall a. Num a => a -> a
signum forall a. Num a => a -> a
signum

  fromInteger :: Integer -> Biap bi a b
fromInteger Integer
n = forall (p :: * -> * -> *) a b. Biapplicative p => a -> b -> p a b
bipure (forall a. Num a => Integer -> a
fromInteger Integer
n) (forall a. Num a => Integer -> a
fromInteger Integer
n)

#if __GLASGOW_HASKELL__ >= 702 && __GLASGOW_HASKELL__ < 706
data BiapMetaData
data BiapMetaCons
data BiapMetaSel

instance Datatype BiapMetaData where
    datatypeName = const "Biap"
    moduleName = const "Data.Bifunctor.Wrapped"

instance Constructor BiapMetaCons where
    conName = const "Biap"
    conIsRecord = const True

instance Selector BiapMetaSel where
    selName = const "getBiap"

instance Generic1 (Biap p a) where
    type Rep1 (Biap p a) = D1 BiapMetaData
        (C1 BiapMetaCons
            (S1 BiapMetaSel (Rec1 (p a))))
    from1 = M1 . M1 . M1 . Rec1 . getBiap
    to1 = Biap . unRec1 . unM1 . unM1 . unM1
#endif