    {-# OPTIONS_GHC -fno-warn-orphans #-}
    module Test.QuickCheck.Instances.These () where

    import Prelude ()
    import Test.QuickCheck.Instances.CustomPrelude

    import Test.QuickCheck

    import Data.Functor.These (These1 (..))
    import Data.These         (These (..))

    -------------------------------------------------------------------------------
    -- These
    -------------------------------------------------------------------------------

    -- | @since 0.3.23
    instance Arbitrary2 These where
        liftArbitrary2 :: forall a b. Gen a -> Gen b -> Gen (These a b)
    liftArbitrary2 Gen a
    arbA Gen b
    arbB = [Gen (These a b)] -> Gen (These a b)
    forall a. HasCallStack => [Gen a] -> Gen a
    oneof
            [ a -> These a b
    forall a b. a -> These a b
    This (a -> These a b) -> Gen a -> Gen (These a b)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen a
    arbA
            , b -> These a b
    forall a b. b -> These a b
    That (b -> These a b) -> Gen b -> Gen (These a b)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen b
    arbB
            , a -> b -> These a b
    forall a b. a -> b -> These a b
    These (a -> b -> These a b) -> Gen a -> Gen (b -> These a b)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen a
    arbA Gen (b -> These a b) -> Gen b -> Gen (These a b)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen b
    arbB
            ]

        liftShrink2 :: forall a b. (a -> [a]) -> (b -> [b]) -> These a b -> [These a b]
    liftShrink2  a -> [a]
    shrA b -> [b]
    _shrB (This a
    x) = a -> These a b
    forall a b. a -> These a b
    This (a -> These a b) -> [a] -> [These a b]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> a -> [a]
    shrA a
    x
        liftShrink2 a -> [a]
    _shrA  b -> [b]
    shrB (That b
    y) = b -> These a b
    forall a b. b -> These a b
    That (b -> These a b) -> [b] -> [These a b]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> b -> [b]
    shrB b
    y
        liftShrink2  a -> [a]
    shrA  b -> [b]
    shrB (These a
    x b
    y) =
            [a -> These a b
    forall a b. a -> These a b
    This a
    x, b -> These a b
    forall a b. b -> These a b
    That b
    y] [These a b] -> [These a b] -> [These a b]
    forall a. [a] -> [a] -> [a]
    ++ [a -> b -> These a b
    forall a b. a -> b -> These a b
    These a
    x' b
    y' | (a
    x', b
    y') <- (a -> [a]) -> (b -> [b]) -> (a, b) -> [(a, b)]
    forall a b. (a -> [a]) -> (b -> [b]) -> (a, b) -> [(a, b)]
    forall (f :: * -> * -> *) a b.
    Arbitrary2 f =>
    (a -> [a]) -> (b -> [b]) -> f a b -> [f a b]
    liftShrink2 a -> [a]
    shrA b -> [b]
    shrB (a
    x, b
    y)]

    -- | @since 0.3.23
    instance (Arbitrary a) => Arbitrary1 (These a) where
        liftArbitrary :: forall a. Gen a -> Gen (These a a)
    liftArbitrary = Gen a -> Gen a -> Gen (These a a)
    forall a b. Gen a -> Gen b -> Gen (These a b)
    forall (f :: * -> * -> *) a b.
    Arbitrary2 f =>
    Gen a -> Gen b -> Gen (f a b)
    liftArbitrary2 Gen a
    forall a. Arbitrary a => Gen a
    arbitrary
        liftShrink :: forall a. (a -> [a]) -> These a a -> [These a a]
    liftShrink = (a -> [a]) -> (a -> [a]) -> These a a -> [These a a]
    forall a b. (a -> [a]) -> (b -> [b]) -> These a b -> [These a b]
    forall (f :: * -> * -> *) a b.
    Arbitrary2 f =>
    (a -> [a]) -> (b -> [b]) -> f a b -> [f a b]
    liftShrink2 a -> [a]
    forall a. Arbitrary a => a -> [a]
    shrink

    -- | @since 0.3.23
    instance (Arbitrary a, Arbitrary b) => Arbitrary (These a b) where
        arbitrary :: Gen (These a b)
    arbitrary = Gen (These a b)
    forall (f :: * -> *) a. (Arbitrary1 f, Arbitrary a) => Gen (f a)
    arbitrary1
        shrink :: These a b -> [These a b]
    shrink = These a b -> [These a b]
    forall (f :: * -> *) a. (Arbitrary1 f, Arbitrary a) => f a -> [f a]
    shrink1

    -- | @since 0.3.23
    instance (Function a, Function b) => Function (These a b) where
      function :: forall b. (These a b -> b) -> These a b :-> b
    function = (These a b -> Either a (Either b (a, b)))
    -> (Either a (Either b (a, b)) -> These a b)
    -> (These a b -> b)
    -> These a b :-> b
    forall b a c.
    Function b =>
    (a -> b) -> (b -> a) -> (a -> c) -> a :-> c
    functionMap These a b -> Either a (Either b (a, b))
    forall {a} {b}. These a b -> Either a (Either b (a, b))
    g Either a (Either b (a, b)) -> These a b
    forall {a} {b}. Either a (Either b (a, b)) -> These a b
    f
        where
          g :: These a b -> Either a (Either b (a, b))
    g (This a
    a)    = a -> Either a (Either b (a, b))
    forall a b. a -> Either a b
    Left a
    a
          g (That b
    b)    = Either b (a, b) -> Either a (Either b (a, b))
    forall a b. b -> Either a b
    Right (b -> Either b (a, b)
    forall a b. a -> Either a b
    Left b
    b)
          g (These a
    a b
    b) = Either b (a, b) -> Either a (Either b (a, b))
    forall a b. b -> Either a b
    Right ((a, b) -> Either b (a, b)
    forall a b. b -> Either a b
    Right (a
    a, b
    b))

          f :: Either a (Either b (a, b)) -> These a b
    f (Left a
    a)               = a -> These a b
    forall a b. a -> These a b
    This a
    a
          f (Right (Left b
    b))       = b -> These a b
    forall a b. b -> These a b
    That b
    b
          f (Right (Right (a
    a, b
    b))) = a -> b -> These a b
    forall a b. a -> b -> These a b
    These a
    a b
    b

    -- | @since 0.3.23
    instance (CoArbitrary a, CoArbitrary b) => CoArbitrary (These a b)

    -------------------------------------------------------------------------------
    -- These1
    -------------------------------------------------------------------------------

    -- | @since 0.3.23
    instance (Arbitrary1 f, Arbitrary1 g) => Arbitrary1 (These1 f g) where
        liftArbitrary :: forall a. Gen a -> Gen (These1 f g a)
    liftArbitrary Gen a
    arb = [Gen (These1 f g a)] -> Gen (These1 f g a)
    forall a. HasCallStack => [Gen a] -> Gen a
    oneof
            [ f a -> These1 f g a
    forall (f :: * -> *) (g :: * -> *) a. f a -> These1 f g a
    This1 (f a -> These1 f g a) -> Gen (f a) -> Gen (These1 f g a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen a -> Gen (f a)
    forall a. Gen a -> Gen (f a)
    forall (f :: * -> *) a. Arbitrary1 f => Gen a -> Gen (f a)
    liftArbitrary Gen a
    arb
            , g a -> These1 f g a
    forall (f :: * -> *) (g :: * -> *) a. g a -> These1 f g a
    That1 (g a -> These1 f g a) -> Gen (g a) -> Gen (These1 f g a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen a -> Gen (g a)
    forall a. Gen a -> Gen (g a)
    forall (f :: * -> *) a. Arbitrary1 f => Gen a -> Gen (f a)
    liftArbitrary Gen a
    arb
            , f a -> g a -> These1 f g a
    forall (f :: * -> *) (g :: * -> *) a. f a -> g a -> These1 f g a
    These1 (f a -> g a -> These1 f g a)
    -> Gen (f a) -> Gen (g a -> These1 f g a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen a -> Gen (f a)
    forall a. Gen a -> Gen (f a)
    forall (f :: * -> *) a. Arbitrary1 f => Gen a -> Gen (f a)
    liftArbitrary Gen a
    arb Gen (g a -> These1 f g a) -> Gen (g a) -> Gen (These1 f g a)
    forall a b. Gen (a -> b) -> Gen a -> Gen b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Gen a -> Gen (g a)
    forall a. Gen a -> Gen (g a)
    forall (f :: * -> *) a. Arbitrary1 f => Gen a -> Gen (f a)
    liftArbitrary Gen a
    arb
            ]

        liftShrink :: forall a. (a -> [a]) -> These1 f g a -> [These1 f g a]
    liftShrink a -> [a]
    shr (This1 f a
    x) = f a -> These1 f g a
    forall (f :: * -> *) (g :: * -> *) a. f a -> These1 f g a
    This1 (f a -> These1 f g a) -> [f a] -> [These1 f g a]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (a -> [a]) -> f a -> [f a]
    forall a. (a -> [a]) -> f a -> [f a]
    forall (f :: * -> *) a. Arbitrary1 f => (a -> [a]) -> f a -> [f a]
    liftShrink a -> [a]
    shr f a
    x
        liftShrink a -> [a]
    shr (That1 g a
    y) = g a -> These1 f g a
    forall (f :: * -> *) (g :: * -> *) a. g a -> These1 f g a
    That1 (g a -> These1 f g a) -> [g a] -> [These1 f g a]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (a -> [a]) -> g a -> [g a]
    forall a. (a -> [a]) -> g a -> [g a]
    forall (f :: * -> *) a. Arbitrary1 f => (a -> [a]) -> f a -> [f a]
    liftShrink a -> [a]
    shr g a
    y
        liftShrink a -> [a]
    shr (These1 f a
    x g a
    y) =
            [ f a -> These1 f g a
    forall (f :: * -> *) (g :: * -> *) a. f a -> These1 f g a
    This1 f a
    x, g a -> These1 f g a
    forall (f :: * -> *) (g :: * -> *) a. g a -> These1 f g a
    That1 g a
    y ] [These1 f g a] -> [These1 f g a] -> [These1 f g a]
    forall a. [a] -> [a] -> [a]
    ++
            [ f a -> g a -> These1 f g a
    forall (f :: * -> *) (g :: * -> *) a. f a -> g a -> These1 f g a
    These1 f a
    x' g a
    y'
            | (f a
    x', g a
    y') <- (f a -> [f a]) -> (g a -> [g a]) -> (f a, g a) -> [(f a, g a)]
    forall a b. (a -> [a]) -> (b -> [b]) -> (a, b) -> [(a, b)]
    forall (f :: * -> * -> *) a b.
    Arbitrary2 f =>
    (a -> [a]) -> (b -> [b]) -> f a b -> [f a b]
    liftShrink2 ((a -> [a]) -> f a -> [f a]
    forall a. (a -> [a]) -> f a -> [f a]
    forall (f :: * -> *) a. Arbitrary1 f => (a -> [a]) -> f a -> [f a]
    liftShrink a -> [a]
    shr) ((a -> [a]) -> g a -> [g a]
    forall a. (a -> [a]) -> g a -> [g a]
    forall (f :: * -> *) a. Arbitrary1 f => (a -> [a]) -> f a -> [f a]
    liftShrink a -> [a]
    shr) (f a
    x, g a
    y)
            ]

    -- | @since 0.3.23
    instance (Arbitrary1 f, Arbitrary1 g, Arbitrary a) => Arbitrary (These1 f g a) where
        arbitrary :: Gen (These1 f g a)
    arbitrary = Gen (These1 f g a)
    forall (f :: * -> *) a. (Arbitrary1 f, Arbitrary a) => Gen (f a)
    arbitrary1
        shrink :: These1 f g a -> [These1 f g a]
    shrink    = These1 f g a -> [These1 f g a]
    forall (f :: * -> *) a. (Arbitrary1 f, Arbitrary a) => f a -> [f a]
    shrink1