    {-# LANGUAGE DeriveFoldable #-}
    {-# LANGUAGE DeriveFunctor #-}
    {-# LANGUAGE DeriveGeneric #-}
    {-# LANGUAGE DeriveTraversable #-}
    {-# LANGUAGE EmptyDataDecls #-}
    {-# LANGUAGE FlexibleContexts #-}
    {-# LANGUAGE PolyKinds #-}
    {-# LANGUAGE Safe #-}
    {-# LANGUAGE StandaloneDeriving #-}
    {-# LANGUAGE TypeFamilies #-}

    module Data.Bifunctor.Sum where

    import Data.Bifunctor
    import Data.Bifunctor.Functor
    import Data.Bifunctor.Swap (Swap (..))
    import Data.Bifoldable
    import Data.Bitraversable
    import Data.Functor.Classes
    import GHC.Generics

    data Sum p q a b = L2 (p a b) | R2 (q a b)
      deriving (Sum p q a b -> Sum p q a b -> Bool
    (Sum p q a b -> Sum p q a b -> Bool)
    -> (Sum p q a b -> Sum p q a b -> Bool) -> Eq (Sum p q a b)
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Eq (p a b), Eq (q a b)) =>
    Sum p q a b -> Sum p q a b -> Bool
    $c== :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Eq (p a b), Eq (q a b)) =>
    Sum p q a b -> Sum p q a b -> Bool
    == :: Sum p q a b -> Sum p q a b -> Bool
    $c/= :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Eq (p a b), Eq (q a b)) =>
    Sum p q a b -> Sum p q a b -> Bool
    /= :: Sum p q a b -> Sum p q a b -> Bool
    Eq, Eq (Sum p q a b)
    Eq (Sum p q a b) =>
    (Sum p q a b -> Sum p q a b -> Ordering)
    -> (Sum p q a b -> Sum p q a b -> Bool)
    -> (Sum p q a b -> Sum p q a b -> Bool)
    -> (Sum p q a b -> Sum p q a b -> Bool)
    -> (Sum p q a b -> Sum p q a b -> Bool)
    -> (Sum p q a b -> Sum p q a b -> Sum p q a b)
    -> (Sum p q a b -> Sum p q a b -> Sum p q a b)
    -> Ord (Sum p q a b)
    Sum p q a b -> Sum p q a b -> Bool
    Sum p q a b -> Sum p q a b -> Ordering
    Sum p q a b -> Sum p q a b -> Sum p q 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 k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Ord (p a b), Ord (q a b)) =>
    Eq (Sum p q a b)
    forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Ord (p a b), Ord (q a b)) =>
    Sum p q a b -> Sum p q a b -> Bool
    forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Ord (p a b), Ord (q a b)) =>
    Sum p q a b -> Sum p q a b -> Ordering
    forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Ord (p a b), Ord (q a b)) =>
    Sum p q a b -> Sum p q a b -> Sum p q a b
    $ccompare :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Ord (p a b), Ord (q a b)) =>
    Sum p q a b -> Sum p q a b -> Ordering
    compare :: Sum p q a b -> Sum p q a b -> Ordering
    $c< :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Ord (p a b), Ord (q a b)) =>
    Sum p q a b -> Sum p q a b -> Bool
    < :: Sum p q a b -> Sum p q a b -> Bool
    $c<= :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Ord (p a b), Ord (q a b)) =>
    Sum p q a b -> Sum p q a b -> Bool
    <= :: Sum p q a b -> Sum p q a b -> Bool
    $c> :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Ord (p a b), Ord (q a b)) =>
    Sum p q a b -> Sum p q a b -> Bool
    > :: Sum p q a b -> Sum p q a b -> Bool
    $c>= :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Ord (p a b), Ord (q a b)) =>
    Sum p q a b -> Sum p q a b -> Bool
    >= :: Sum p q a b -> Sum p q a b -> Bool
    $cmax :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Ord (p a b), Ord (q a b)) =>
    Sum p q a b -> Sum p q a b -> Sum p q a b
    max :: Sum p q a b -> Sum p q a b -> Sum p q a b
    $cmin :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Ord (p a b), Ord (q a b)) =>
    Sum p q a b -> Sum p q a b -> Sum p q a b
    min :: Sum p q a b -> Sum p q a b -> Sum p q a b
    Ord, Int -> Sum p q a b -> ShowS
    [Sum p q a b] -> ShowS
    Sum p q a b -> String
    (Int -> Sum p q a b -> ShowS)
    -> (Sum p q a b -> String)
    -> ([Sum p q a b] -> ShowS)
    -> Show (Sum p q a b)
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Show (p a b), Show (q a b)) =>
    Int -> Sum p q a b -> ShowS
    forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Show (p a b), Show (q a b)) =>
    [Sum p q a b] -> ShowS
    forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Show (p a b), Show (q a b)) =>
    Sum p q a b -> String
    $cshowsPrec :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Show (p a b), Show (q a b)) =>
    Int -> Sum p q a b -> ShowS
    showsPrec :: Int -> Sum p q a b -> ShowS
    $cshow :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Show (p a b), Show (q a b)) =>
    Sum p q a b -> String
    show :: Sum p q a b -> String
    $cshowList :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Show (p a b), Show (q a b)) =>
    [Sum p q a b] -> ShowS
    showList :: [Sum p q a b] -> ShowS
    Show, ReadPrec [Sum p q a b]
    ReadPrec (Sum p q a b)
    Int -> ReadS (Sum p q a b)
    ReadS [Sum p q a b]
    (Int -> ReadS (Sum p q a b))
    -> ReadS [Sum p q a b]
    -> ReadPrec (Sum p q a b)
    -> ReadPrec [Sum p q a b]
    -> Read (Sum p q a b)
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Read (p a b), Read (q a b)) =>
    ReadPrec [Sum p q a b]
    forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Read (p a b), Read (q a b)) =>
    ReadPrec (Sum p q a b)
    forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Read (p a b), Read (q a b)) =>
    Int -> ReadS (Sum p q a b)
    forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Read (p a b), Read (q a b)) =>
    ReadS [Sum p q a b]
    $creadsPrec :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Read (p a b), Read (q a b)) =>
    Int -> ReadS (Sum p q a b)
    readsPrec :: Int -> ReadS (Sum p q a b)
    $creadList :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Read (p a b), Read (q a b)) =>
    ReadS [Sum p q a b]
    readList :: ReadS [Sum p q a b]
    $creadPrec :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Read (p a b), Read (q a b)) =>
    ReadPrec (Sum p q a b)
    readPrec :: ReadPrec (Sum p q a b)
    $creadListPrec :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k).
    (Read (p a b), Read (q a b)) =>
    ReadPrec [Sum p q a b]
    readListPrec :: ReadPrec [Sum p q a b]
    Read, (forall x. Sum p q a b -> Rep (Sum p q a b) x)
    -> (forall x. Rep (Sum p q a b) x -> Sum p q a b)
    -> Generic (Sum p q a b)
    forall x. Rep (Sum p q a b) x -> Sum p q a b
    forall x. Sum p q a b -> Rep (Sum p q a b) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k)
           x.
    Rep (Sum p q a b) x -> Sum p q a b
    forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k)
           x.
    Sum p q a b -> Rep (Sum p q a b) x
    $cfrom :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k)
           x.
    Sum p q a b -> Rep (Sum p q a b) x
    from :: forall x. Sum p q a b -> Rep (Sum p q a b) x
    $cto :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (b :: k)
           x.
    Rep (Sum p q a b) x -> Sum p q a b
    to :: forall x. Rep (Sum p q a b) x -> Sum p q a b
    Generic, (forall (a :: k). Sum p q a a -> Rep1 (Sum p q a) a)
    -> (forall (a :: k). Rep1 (Sum p q a) a -> Sum p q a a)
    -> Generic1 (Sum p q a)
    forall (a :: k). Rep1 (Sum p q a) a -> Sum p q a a
    forall (a :: k). Sum p q a a -> Rep1 (Sum p q a) a
    forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (a :: k).
    Rep1 (Sum p q a) a -> Sum p q a a
    forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (a :: k).
    Sum p q a a -> Rep1 (Sum p q a) a
    forall k (f :: k -> *).
    (forall (a :: k). f a -> Rep1 f a)
    -> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
    $cfrom1 :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (a :: k).
    Sum p q a a -> Rep1 (Sum p q a) a
    from1 :: forall (a :: k). Sum p q a a -> Rep1 (Sum p q a) a
    $cto1 :: forall k k (p :: k -> k -> *) (q :: k -> k -> *) (a :: k) (a :: k).
    Rep1 (Sum p q a) a -> Sum p q a a
    to1 :: forall (a :: k). Rep1 (Sum p q a) a -> Sum p q a a
    Generic1)
    deriving instance (Functor (f a), Functor (g a)) => Functor (Sum f g a)
    deriving instance (Foldable (f a), Foldable (g a)) => Foldable (Sum f g a)
    deriving instance (Traversable (f a), Traversable (g a)) => Traversable (Sum f g a)

    instance (Eq2 f, Eq2 g, Eq a) => Eq1 (Sum f g a) where
      liftEq :: forall a b. (a -> b -> Bool) -> Sum f g a a -> Sum f g a b -> Bool
    liftEq = (a -> a -> Bool)
    -> (a -> b -> Bool) -> Sum f g a a -> Sum f g a b -> Bool
    forall a b c d.
    (a -> b -> Bool)
    -> (c -> d -> Bool) -> Sum f g a c -> Sum f g b d -> Bool
    forall (f :: * -> * -> *) a b c d.
    Eq2 f =>
    (a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool
    liftEq2 a -> a -> Bool
    forall a. Eq a => a -> a -> Bool
    (==)
    instance (Eq2 f, Eq2 g) => Eq2 (Sum f g) where
      liftEq2 :: forall a b c d.
    (a -> b -> Bool)
    -> (c -> d -> Bool) -> Sum f g a c -> Sum f g b d -> Bool
    liftEq2 a -> b -> Bool
    f c -> d -> Bool
    g (L2 f a c
    x1) (L2 f b d
    x2) = (a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool
    forall a b c d.
    (a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool
    forall (f :: * -> * -> *) a b c d.
    Eq2 f =>
    (a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool
    liftEq2 a -> b -> Bool
    f c -> d -> Bool
    g f a c
    x1 f b d
    x2
      liftEq2 a -> b -> Bool
    _ c -> d -> Bool
    _ (L2 f a c
    _)  (R2 g b d
    _)  = Bool
    False
      liftEq2 a -> b -> Bool
    _ c -> d -> Bool
    _ (R2 g a c
    _)  (L2 f b d
    _)  = Bool
    False
      liftEq2 a -> b -> Bool
    f c -> d -> Bool
    g (R2 g a c
    y1) (R2 g b d
    y2) = (a -> b -> Bool) -> (c -> d -> Bool) -> g a c -> g b d -> Bool
    forall a b c d.
    (a -> b -> Bool) -> (c -> d -> Bool) -> g a c -> g b d -> Bool
    forall (f :: * -> * -> *) a b c d.
    Eq2 f =>
    (a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool
    liftEq2 a -> b -> Bool
    f c -> d -> Bool
    g g a c
    y1 g b d
    y2

    instance (Ord2 f, Ord2 g, Ord a) => Ord1 (Sum f g a) where
      liftCompare :: forall a b.
    (a -> b -> Ordering) -> Sum f g a a -> Sum f g a b -> Ordering
    liftCompare = (a -> a -> Ordering)
    -> (a -> b -> Ordering) -> Sum f g a a -> Sum f g a b -> Ordering
    forall a b c d.
    (a -> b -> Ordering)
    -> (c -> d -> Ordering) -> Sum f g a c -> Sum f g b d -> Ordering
    forall (f :: * -> * -> *) a b c d.
    Ord2 f =>
    (a -> b -> Ordering)
    -> (c -> d -> Ordering) -> f a c -> f b d -> Ordering
    liftCompare2 a -> a -> Ordering
    forall a. Ord a => a -> a -> Ordering
    compare
    instance (Ord2 f, Ord2 g) => Ord2 (Sum f g) where
      liftCompare2 :: forall a b c d.
    (a -> b -> Ordering)
    -> (c -> d -> Ordering) -> Sum f g a c -> Sum f g b d -> Ordering
    liftCompare2 a -> b -> Ordering
    f c -> d -> Ordering
    g (L2 f a c
    x1) (L2 f b d
    x2) = (a -> b -> Ordering)
    -> (c -> d -> Ordering) -> f a c -> f b d -> Ordering
    forall a b c d.
    (a -> b -> Ordering)
    -> (c -> d -> Ordering) -> f a c -> f b d -> Ordering
    forall (f :: * -> * -> *) a b c d.
    Ord2 f =>
    (a -> b -> Ordering)
    -> (c -> d -> Ordering) -> f a c -> f b d -> Ordering
    liftCompare2 a -> b -> Ordering
    f c -> d -> Ordering
    g f a c
    x1 f b d
    x2
      liftCompare2 a -> b -> Ordering
    _ c -> d -> Ordering
    _ (L2 f a c
    _)  (R2 g b d
    _)  = Ordering
    LT
      liftCompare2 a -> b -> Ordering
    _ c -> d -> Ordering
    _ (R2 g a c
    _)  (L2 f b d
    _)  = Ordering
    GT
      liftCompare2 a -> b -> Ordering
    f c -> d -> Ordering
    g (R2 g a c
    y1) (R2 g b d
    y2) = (a -> b -> Ordering)
    -> (c -> d -> Ordering) -> g a c -> g b d -> Ordering
    forall a b c d.
    (a -> b -> Ordering)
    -> (c -> d -> Ordering) -> g a c -> g b d -> Ordering
    forall (f :: * -> * -> *) a b c d.
    Ord2 f =>
    (a -> b -> Ordering)
    -> (c -> d -> Ordering) -> f a c -> f b d -> Ordering
    liftCompare2 a -> b -> Ordering
    f c -> d -> Ordering
    g g a c
    y1 g b d
    y2

    instance (Read2 f, Read2 g, Read a) => Read1 (Sum f g a) where
      liftReadsPrec :: forall a.
    (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Sum f g a a)
    liftReadsPrec = (Int -> ReadS a)
    -> ReadS [a]
    -> (Int -> ReadS a)
    -> ReadS [a]
    -> Int
    -> ReadS (Sum f g a a)
    forall a b.
    (Int -> ReadS a)
    -> ReadS [a]
    -> (Int -> ReadS b)
    -> ReadS [b]
    -> Int
    -> ReadS (Sum f g a b)
    forall (f :: * -> * -> *) a b.
    Read2 f =>
    (Int -> ReadS a)
    -> ReadS [a]
    -> (Int -> ReadS b)
    -> ReadS [b]
    -> Int
    -> ReadS (f a b)
    liftReadsPrec2 Int -> ReadS a
    forall a. Read a => Int -> ReadS a
    readsPrec ReadS [a]
    forall a. Read a => ReadS [a]
    readList
    instance (Read2 f, Read2 g) => Read2 (Sum f g) where
      liftReadsPrec2 :: forall a b.
    (Int -> ReadS a)
    -> ReadS [a]
    -> (Int -> ReadS b)
    -> ReadS [b]
    -> Int
    -> ReadS (Sum f g a b)
    liftReadsPrec2 Int -> ReadS a
    rp1 ReadS [a]
    rl1 Int -> ReadS b
    rp2 ReadS [b]
    rl2 = (String -> ReadS (Sum f g a b)) -> Int -> ReadS (Sum f g a b)
    forall a. (String -> ReadS a) -> Int -> ReadS a
    readsData ((String -> ReadS (Sum f g a b)) -> Int -> ReadS (Sum f g a b))
    -> (String -> ReadS (Sum f g a b)) -> Int -> ReadS (Sum f g a b)
    forall a b. (a -> b) -> a -> b
    $
        (Int -> ReadS (f a b))
    -> String
    -> (f a b -> Sum f g a b)
    -> String
    -> ReadS (Sum f g a b)
    forall a t.
    (Int -> ReadS a) -> String -> (a -> t) -> String -> ReadS t
    readsUnaryWith ((Int -> ReadS a)
    -> ReadS [a]
    -> (Int -> ReadS b)
    -> ReadS [b]
    -> Int
    -> ReadS (f a b)
    forall a b.
    (Int -> ReadS a)
    -> ReadS [a]
    -> (Int -> ReadS b)
    -> ReadS [b]
    -> Int
    -> ReadS (f a b)
    forall (f :: * -> * -> *) a b.
    Read2 f =>
    (Int -> ReadS a)
    -> ReadS [a]
    -> (Int -> ReadS b)
    -> ReadS [b]
    -> Int
    -> ReadS (f a b)
    liftReadsPrec2 Int -> ReadS a
    rp1 ReadS [a]
    rl1 Int -> ReadS b
    rp2 ReadS [b]
    rl2) String
    "L2" f a b -> Sum f g a b
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    p a b -> Sum p q a b
    L2 (String -> ReadS (Sum f g a b))
    -> (String -> ReadS (Sum f g a b)) -> String -> ReadS (Sum f g a b)
    forall a. Monoid a => a -> a -> a
    `mappend`
        (Int -> ReadS (g a b))
    -> String
    -> (g a b -> Sum f g a b)
    -> String
    -> ReadS (Sum f g a b)
    forall a t.
    (Int -> ReadS a) -> String -> (a -> t) -> String -> ReadS t
    readsUnaryWith ((Int -> ReadS a)
    -> ReadS [a]
    -> (Int -> ReadS b)
    -> ReadS [b]
    -> Int
    -> ReadS (g a b)
    forall a b.
    (Int -> ReadS a)
    -> ReadS [a]
    -> (Int -> ReadS b)
    -> ReadS [b]
    -> Int
    -> ReadS (g a b)
    forall (f :: * -> * -> *) a b.
    Read2 f =>
    (Int -> ReadS a)
    -> ReadS [a]
    -> (Int -> ReadS b)
    -> ReadS [b]
    -> Int
    -> ReadS (f a b)
    liftReadsPrec2 Int -> ReadS a
    rp1 ReadS [a]
    rl1 Int -> ReadS b
    rp2 ReadS [b]
    rl2) String
    "R2" g a b -> Sum f g a b
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    q a b -> Sum p q a b
    R2

    instance (Show2 f, Show2 g, Show a) => Show1 (Sum f g a) where
      liftShowsPrec :: forall a.
    (Int -> a -> ShowS)
    -> ([a] -> ShowS) -> Int -> Sum f g a a -> ShowS
    liftShowsPrec = (Int -> a -> ShowS)
    -> ([a] -> ShowS)
    -> (Int -> a -> ShowS)
    -> ([a] -> ShowS)
    -> Int
    -> Sum f g a a
    -> ShowS
    forall a b.
    (Int -> a -> ShowS)
    -> ([a] -> ShowS)
    -> (Int -> b -> ShowS)
    -> ([b] -> ShowS)
    -> Int
    -> Sum f g a b
    -> ShowS
    forall (f :: * -> * -> *) a b.
    Show2 f =>
    (Int -> a -> ShowS)
    -> ([a] -> ShowS)
    -> (Int -> b -> ShowS)
    -> ([b] -> ShowS)
    -> Int
    -> f a b
    -> ShowS
    liftShowsPrec2 Int -> a -> ShowS
    forall a. Show a => Int -> a -> ShowS
    showsPrec [a] -> ShowS
    forall a. Show a => [a] -> ShowS
    showList
    instance (Show2 f, Show2 g) => Show2 (Sum f g) where
      liftShowsPrec2 :: forall a b.
    (Int -> a -> ShowS)
    -> ([a] -> ShowS)
    -> (Int -> b -> ShowS)
    -> ([b] -> ShowS)
    -> Int
    -> Sum f g a b
    -> ShowS
    liftShowsPrec2 Int -> a -> ShowS
    sp1 [a] -> ShowS
    sl1 Int -> b -> ShowS
    sp2 [b] -> ShowS
    sl2 Int
    p (L2 f a b
    x) =
        (Int -> f a b -> ShowS) -> String -> Int -> f a b -> ShowS
    forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
    showsUnaryWith ((Int -> a -> ShowS)
    -> ([a] -> ShowS)
    -> (Int -> b -> ShowS)
    -> ([b] -> ShowS)
    -> Int
    -> f a b
    -> ShowS
    forall a b.
    (Int -> a -> ShowS)
    -> ([a] -> ShowS)
    -> (Int -> b -> ShowS)
    -> ([b] -> ShowS)
    -> Int
    -> f a b
    -> ShowS
    forall (f :: * -> * -> *) a b.
    Show2 f =>
    (Int -> a -> ShowS)
    -> ([a] -> ShowS)
    -> (Int -> b -> ShowS)
    -> ([b] -> ShowS)
    -> Int
    -> f a b
    -> ShowS
    liftShowsPrec2 Int -> a -> ShowS
    sp1 [a] -> ShowS
    sl1 Int -> b -> ShowS
    sp2 [b] -> ShowS
    sl2) String
    "L2" Int
    p f a b
    x
      liftShowsPrec2 Int -> a -> ShowS
    sp1 [a] -> ShowS
    sl1 Int -> b -> ShowS
    sp2 [b] -> ShowS
    sl2 Int
    p (R2 g a b
    y) =
        (Int -> g a b -> ShowS) -> String -> Int -> g a b -> ShowS
    forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
    showsUnaryWith ((Int -> a -> ShowS)
    -> ([a] -> ShowS)
    -> (Int -> b -> ShowS)
    -> ([b] -> ShowS)
    -> Int
    -> g a b
    -> ShowS
    forall a b.
    (Int -> a -> ShowS)
    -> ([a] -> ShowS)
    -> (Int -> b -> ShowS)
    -> ([b] -> ShowS)
    -> Int
    -> g a b
    -> ShowS
    forall (f :: * -> * -> *) a b.
    Show2 f =>
    (Int -> a -> ShowS)
    -> ([a] -> ShowS)
    -> (Int -> b -> ShowS)
    -> ([b] -> ShowS)
    -> Int
    -> f a b
    -> ShowS
    liftShowsPrec2 Int -> a -> ShowS
    sp1 [a] -> ShowS
    sl1 Int -> b -> ShowS
    sp2 [b] -> ShowS
    sl2) String
    "R2" Int
    p g a b
    y

    instance (Bifunctor p, Bifunctor q) => Bifunctor (Sum p q) where
      bimap :: forall a b c d. (a -> b) -> (c -> d) -> Sum p q a c -> Sum p q b d
    bimap a -> b
    f c -> d
    g (L2 p a c
    p) = p b d -> Sum p q b d
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    p a b -> Sum p q a b
    L2 ((a -> b) -> (c -> d) -> p a c -> p b d
    forall a b c d. (a -> b) -> (c -> d) -> p a c -> p b d
    forall (p :: * -> * -> *) a b c d.
    Bifunctor p =>
    (a -> b) -> (c -> d) -> p a c -> p b d
    bimap a -> b
    f c -> d
    g p a c
    p)
      bimap a -> b
    f c -> d
    g (R2 q a c
    q) = q b d -> Sum p q b d
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    q a b -> Sum p q a b
    R2 ((a -> b) -> (c -> d) -> q a c -> q b d
    forall a b c d. (a -> b) -> (c -> d) -> q a c -> q b d
    forall (p :: * -> * -> *) a b c d.
    Bifunctor p =>
    (a -> b) -> (c -> d) -> p a c -> p b d
    bimap a -> b
    f c -> d
    g q a c
    q)
      first :: forall a b c. (a -> b) -> Sum p q a c -> Sum p q b c
    first a -> b
    f (L2 p a c
    p) = p b c -> Sum p q b c
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    p a b -> Sum p q a b
    L2 ((a -> b) -> p a c -> p b c
    forall a b c. (a -> b) -> p a c -> p b c
    forall (p :: * -> * -> *) a b c.
    Bifunctor p =>
    (a -> b) -> p a c -> p b c
    first a -> b
    f p a c
    p)
      first a -> b
    f (R2 q a c
    q) = q b c -> Sum p q b c
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    q a b -> Sum p q a b
    R2 ((a -> b) -> q a c -> q b c
    forall a b c. (a -> b) -> q a c -> q b c
    forall (p :: * -> * -> *) a b c.
    Bifunctor p =>
    (a -> b) -> p a c -> p b c
    first a -> b
    f q a c
    q)
      second :: forall b c a. (b -> c) -> Sum p q a b -> Sum p q a c
    second b -> c
    f (L2 p a b
    p) = p a c -> Sum p q a c
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    p a b -> Sum p q a b
    L2 ((b -> c) -> p a b -> p a c
    forall b c a. (b -> c) -> p a b -> p a c
    forall (p :: * -> * -> *) b c a.
    Bifunctor p =>
    (b -> c) -> p a b -> p a c
    second b -> c
    f p a b
    p)
      second b -> c
    f (R2 q a b
    q) = q a c -> Sum p q a c
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    q a b -> Sum p q a b
    R2 ((b -> c) -> q a b -> q a c
    forall b c a. (b -> c) -> q a b -> q a c
    forall (p :: * -> * -> *) b c a.
    Bifunctor p =>
    (b -> c) -> p a b -> p a c
    second b -> c
    f q a b
    q)

    instance (Bifoldable p, Bifoldable q) => Bifoldable (Sum p q) where
      bifoldMap :: forall m a b. Monoid m => (a -> m) -> (b -> m) -> Sum p q a b -> m
    bifoldMap a -> m
    f b -> m
    g (L2 p a b
    p) = (a -> m) -> (b -> m) -> p a b -> m
    forall m a b. Monoid m => (a -> m) -> (b -> m) -> p a b -> m
    forall (p :: * -> * -> *) m a b.
    (Bifoldable p, Monoid m) =>
    (a -> m) -> (b -> m) -> p a b -> m
    bifoldMap a -> m
    f b -> m
    g p a b
    p
      bifoldMap a -> m
    f b -> m
    g (R2 q a b
    q) = (a -> m) -> (b -> m) -> q a b -> m
    forall m a b. Monoid m => (a -> m) -> (b -> m) -> q a b -> m
    forall (p :: * -> * -> *) m a b.
    (Bifoldable p, Monoid m) =>
    (a -> m) -> (b -> m) -> p a b -> m
    bifoldMap a -> m
    f b -> m
    g q a b
    q

    instance (Bitraversable p, Bitraversable q) => Bitraversable (Sum p q) where
      bitraverse :: forall (f :: * -> *) a c b d.
    Applicative f =>
    (a -> f c) -> (b -> f d) -> Sum p q a b -> f (Sum p q c d)
    bitraverse a -> f c
    f b -> f d
    g (L2 p a b
    p) = p c d -> Sum p q c d
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    p a b -> Sum p q a b
    L2 (p c d -> Sum p q c d) -> f (p c d) -> f (Sum p q c d)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (a -> f c) -> (b -> f d) -> p a b -> f (p c d)
    forall (f :: * -> *) a c b d.
    Applicative f =>
    (a -> f c) -> (b -> f d) -> p a b -> f (p c d)
    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 p a b
    p
      bitraverse a -> f c
    f b -> f d
    g (R2 q a b
    q) = q c d -> Sum p q c d
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    q a b -> Sum p q a b
    R2 (q c d -> Sum p q c d) -> f (q c d) -> f (Sum p q c d)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (a -> f c) -> (b -> f d) -> q a b -> f (q c d)
    forall (f :: * -> *) a c b d.
    Applicative f =>
    (a -> f c) -> (b -> f d) -> q a b -> f (q c d)
    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 q a b
    q

    instance BifunctorFunctor (Sum p) where
      bifmap :: forall (p :: k2 -> k3 -> *) (q :: k2 -> k3 -> *).
    (p :-> q) -> Sum p p :-> Sum p q
    bifmap p :-> q
    _ (L2 p a b
    p) = p a b -> Sum p q a b
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    p a b -> Sum p q a b
    L2 p a b
    p
      bifmap p :-> q
    f (R2 p a b
    q) = q a b -> Sum p q a b
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    q a b -> Sum p q a b
    R2 (p a b -> q a b
    p :-> q
    f p a b
    q)

    instance BifunctorMonad (Sum p) where
      bireturn :: forall (p :: k -> k1 -> *). p :-> Sum p p
    bireturn = p a b -> Sum p p a b
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    q a b -> Sum p q a b
    R2
      bijoin :: forall (p :: k -> k1 -> *). Sum p (Sum p p) :-> Sum p p
    bijoin (L2 p a b
    p) = p a b -> Sum p p a b
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    p a b -> Sum p q a b
    L2 p a b
    p
      bijoin (R2 Sum p p a b
    q) = Sum p p a b
    q
      bibind :: forall (p :: k -> k1 -> *) (q :: k -> k1 -> *).
    (p :-> Sum p q) -> Sum p p :-> Sum p q
    bibind p :-> Sum p q
    _ (L2 p a b
    p) = p a b -> Sum p q a b
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    p a b -> Sum p q a b
    L2 p a b
    p
      bibind p :-> Sum p q
    f (R2 p a b
    q) = p a b -> Sum p q a b
    p :-> Sum p q
    f p a b
    q

    -- | @since 5.6.1
    instance (Swap p, Swap q) => Swap (Sum p q) where
      swap :: forall a b. Sum p q a b -> Sum p q b a
    swap (L2 p a b
    p) = p b a -> Sum p q b a
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    p a b -> Sum p q a b
    L2 (p a b -> p b a
    forall a b. p a b -> p b a
    forall (p :: * -> * -> *) a b. Swap p => p a b -> p b a
    swap p a b
    p)
      swap (R2 q a b
    q) = q b a -> Sum p q b a
    forall {k} {k} (p :: k -> k -> *) (q :: k -> k -> *) (a :: k)
           (b :: k).
    q a b -> Sum p q a b
    R2 (q a b -> q b a
    forall a b. q a b -> q b a
    forall (p :: * -> * -> *) a b. Swap p => p a b -> p b a
    swap q a b
    q)