    {-# LANGUAGE ScopedTypeVariables #-}
    {-# LANGUAGE QuantifiedConstraints #-}
    {-# LANGUAGE RankNTypes #-}

    module Hedgehog.Classes.Applicative (applicativeLaws) where

    import Control.Applicative (Applicative(..))

    import Hedgehog
    import Hedgehog.Classes.Common

    -- | Tests the following 'Applicative' laws:
    --
    -- [__Identity__]: @'pure' 'id' '<*>' v@ ≡ @v@
    -- [__Composition__]: @'pure' ('.') '<*>' u '<*>' v '<*>' w@ ≡ @u '<*>' (v '<*>' w)@
    -- [__Homomorphism__]: @'pure' f '<*>' 'pure'@ x ≡ @'pure' (f x)@
    -- [__Interchange__]: @u '<*>' 'pure' y@ ≡ @'pure' ('$' y) '<*>' u@
    -- [__LiftA2 1__]: @'liftA2' 'id' f x@ ≡ @f '<*>' x@
    -- [__LiftA2 2__]: @'liftA2' f x y@ ≡ @f '<$>' x '<*>' y@
    applicativeLaws ::
      ( Applicative f
      , forall x. Eq x => Eq (f x), forall x. Show x => Show (f x)
      ) => (forall x. Gen x -> Gen (f x)) -> Laws
    applicativeLaws :: forall (f :: * -> *).
    (Applicative f, forall x. Eq x => Eq (f x),
     forall x. Show x => Show (f x)) =>
    (forall x. Gen x -> Gen (f x)) -> Laws
    applicativeLaws forall x. Gen x -> Gen (f x)
    gen = String -> [(String, Property)] -> Laws
    Laws String
    "Applicative"
      [ (String
    "Identity", (forall x. Gen x -> Gen (f x)) -> Property
    forall (f :: * -> *). ApplicativeProp f
    applicativeIdentity Gen x -> Gen (f x)
    forall x. Gen x -> Gen (f x)
    gen)
      , (String
    "Composition", (forall x. Gen x -> Gen (f x)) -> Property
    forall (f :: * -> *). ApplicativeProp f
    applicativeComposition Gen x -> Gen (f x)
    forall x. Gen x -> Gen (f x)
    gen)
      , (String
    "Homomorphism", (forall x. Gen x -> Gen (f x)) -> Property
    forall (f :: * -> *). ApplicativeProp f
    applicativeHomomorphism Gen x -> Gen (f x)
    forall x. Gen x -> Gen (f x)
    gen)
      , (String
    "Interchange", (forall x. Gen x -> Gen (f x)) -> Property
    forall (f :: * -> *). ApplicativeProp f
    applicativeInterchange Gen x -> Gen (f x)
    forall x. Gen x -> Gen (f x)
    gen)
      , (String
    "LiftA2 Part 1", (forall x. Gen x -> Gen (f x)) -> Property
    forall (f :: * -> *). ApplicativeProp f
    applicativeLiftA2_1 Gen x -> Gen (f x)
    forall x. Gen x -> Gen (f x)
    gen)
      , (String
    "LiftA2 Part 2", (forall x. Gen x -> Gen (f x)) -> Property
    forall (f :: * -> *). ApplicativeProp f
    applicativeLiftA2_2 GenT Identity x -> GenT Identity (f x)
    forall x. Gen x -> Gen (f x)
    gen)
      ]

    type ApplicativeProp f =
      ( Applicative f
      , forall x. Eq x => Eq (f x), forall x. Show x => Show (f x)
      ) => (forall x. Gen x -> Gen (f x)) -> Property

    applicativeIdentity :: forall f. ApplicativeProp f
    applicativeIdentity :: forall (f :: * -> *). ApplicativeProp f
    applicativeIdentity forall x. Gen x -> Gen (f x)
    fgen = HasCallStack => PropertyT IO () -> Property
    PropertyT IO () -> Property
    property (PropertyT IO () -> Property) -> PropertyT IO () -> Property
    forall a b. (a -> b) -> a -> b
    $ do
      f Integer
    a <- Gen (f Integer) -> PropertyT IO (f Integer)
    forall (m :: * -> *) a.
    (Monad m, Show a, HasCallStack) =>
    Gen a -> PropertyT m a
    forAll (Gen (f Integer) -> PropertyT IO (f Integer))
    -> Gen (f Integer) -> PropertyT IO (f Integer)
    forall a b. (a -> b) -> a -> b
    $ Gen Integer -> Gen (f Integer)
    forall x. Gen x -> Gen (f x)
    fgen Gen Integer
    genSmallInteger
      let lhs :: f Integer
    lhs = (Integer -> Integer) -> f (Integer -> Integer)
    forall a. a -> f a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Integer -> Integer
    forall a. a -> a
    id f (Integer -> Integer) -> f Integer -> f Integer
    forall a b. f (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> f Integer
    a
      let rhs :: f Integer
    rhs = f Integer
    a
      let ctx :: Context
    ctx = LawContext -> Context
    contextualise (LawContext -> Context) -> LawContext -> Context
    forall a b. (a -> b) -> a -> b
    $ LawContext
            { lawContextLawName :: String
    lawContextLawName = String
    "Identity", lawContextLawBody :: String
    lawContextLawBody = String
    "pure id <*> v" String -> String -> String
    `congruency` String
    "v"
            , lawContextTcName :: String
    lawContextTcName = String
    "Applicative", lawContextTcProp :: String
    lawContextTcProp =
                 let showA :: String
    showA = f Integer -> String
    forall a. Show a => a -> String
    show f Integer
    a
                 in [String] -> String
    lawWhere
                     [ String
    "pure id <*> v" String -> String -> String
    `congruency` String
    "v, where"
                     , String
    "v = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    showA
                     ]
            , lawContextReduced :: String
    lawContextReduced = f Integer -> f Integer -> String
    forall a. Show a => a -> a -> String
    reduced f Integer
    lhs f Integer
    rhs
            }
      f Integer -> f Integer -> Context -> PropertyT IO ()
    forall (m :: * -> *) a (f :: * -> *).
    (MonadTest m, HasCallStack, Eq a, Show a,
     forall x. Eq x => Eq (f x), forall x. Show x => Show (f x)) =>
    f a -> f a -> Context -> m ()
    heqCtx1 f Integer
    lhs f Integer
    rhs Context
    ctx

    applicativeComposition :: forall f. ApplicativeProp f
    applicativeComposition :: forall (f :: * -> *). ApplicativeProp f
    applicativeComposition forall x. Gen x -> Gen (f x)
    fgen = HasCallStack => PropertyT IO () -> Property
    PropertyT IO () -> Property
    property (PropertyT IO () -> Property) -> PropertyT IO () -> Property
    forall a b. (a -> b) -> a -> b
    $ do
      f QuadraticEquation
    u' <- Gen (f QuadraticEquation) -> PropertyT IO (f QuadraticEquation)
    forall (m :: * -> *) a.
    (Monad m, Show a, HasCallStack) =>
    Gen a -> PropertyT m a
    forAll (Gen (f QuadraticEquation) -> PropertyT IO (f QuadraticEquation))
    -> Gen (f QuadraticEquation) -> PropertyT IO (f QuadraticEquation)
    forall a b. (a -> b) -> a -> b
    $ Gen QuadraticEquation -> Gen (f QuadraticEquation)
    forall x. Gen x -> Gen (f x)
    fgen Gen QuadraticEquation
    genQuadraticEquation
      f QuadraticEquation
    v' <- Gen (f QuadraticEquation) -> PropertyT IO (f QuadraticEquation)
    forall (m :: * -> *) a.
    (Monad m, Show a, HasCallStack) =>
    Gen a -> PropertyT m a
    forAll (Gen (f QuadraticEquation) -> PropertyT IO (f QuadraticEquation))
    -> Gen (f QuadraticEquation) -> PropertyT IO (f QuadraticEquation)
    forall a b. (a -> b) -> a -> b
    $ Gen QuadraticEquation -> Gen (f QuadraticEquation)
    forall x. Gen x -> Gen (f x)
    fgen Gen QuadraticEquation
    genQuadraticEquation
      Integer
    w' <- Gen Integer -> PropertyT IO Integer
    forall (m :: * -> *) a.
    (Monad m, Show a, HasCallStack) =>
    Gen a -> PropertyT m a
    forAll Gen Integer
    genSmallInteger
      let u :: f (Integer -> Integer)
    u = QuadraticEquation -> Integer -> Integer
    runQuadraticEquation (QuadraticEquation -> Integer -> Integer)
    -> f QuadraticEquation -> f (Integer -> Integer)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> f QuadraticEquation
    u'
          v :: f (Integer -> Integer)
    v = QuadraticEquation -> Integer -> Integer
    runQuadraticEquation (QuadraticEquation -> Integer -> Integer)
    -> f QuadraticEquation -> f (Integer -> Integer)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> f QuadraticEquation
    v'
          w :: f Integer
    w = Integer -> f Integer
    forall a. a -> f a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Integer
    w'
      let lhs :: f Integer
    lhs = ((Integer -> Integer)
     -> (Integer -> Integer) -> Integer -> Integer)
    -> f ((Integer -> Integer)
          -> (Integer -> Integer) -> Integer -> Integer)
    forall a. a -> f a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (Integer -> Integer) -> (Integer -> Integer) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    (.) f ((Integer -> Integer)
       -> (Integer -> Integer) -> Integer -> Integer)
    -> f (Integer -> Integer)
    -> f ((Integer -> Integer) -> Integer -> Integer)
    forall a b. f (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> f (Integer -> Integer)
    u f ((Integer -> Integer) -> Integer -> Integer)
    -> f (Integer -> Integer) -> f (Integer -> Integer)
    forall a b. f (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> f (Integer -> Integer)
    v f (Integer -> Integer) -> f Integer -> f Integer
    forall a b. f (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> f Integer
    w
      let rhs :: f Integer
    rhs = f (Integer -> Integer)
    u f (Integer -> Integer) -> f Integer -> f Integer
    forall a b. f (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (f (Integer -> Integer)
    v f (Integer -> Integer) -> f Integer -> f Integer
    forall a b. f (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> f Integer
    w)
      let ctx :: Context
    ctx = LawContext -> Context
    contextualise (LawContext -> Context) -> LawContext -> Context
    forall a b. (a -> b) -> a -> b
    $ LawContext
            { lawContextLawName :: String
    lawContextLawName = String
    "Composition", lawContextLawBody :: String
    lawContextLawBody = String
    "pure (.) <*> u <*> v <*> w == u <*> (v <*> w)"
            , lawContextTcName :: String
    lawContextTcName = String
    "Applicative", lawContextTcProp :: String
    lawContextTcProp =
                let showU :: String
    showU = f QuadraticEquation -> String
    forall a. Show a => a -> String
    show f QuadraticEquation
    u'; showV :: String
    showV = f QuadraticEquation -> String
    forall a. Show a => a -> String
    show f QuadraticEquation
    v'; showW :: String
    showW = Integer -> String
    forall a. Show a => a -> String
    show Integer
    w';
                in [String] -> String
    lawWhere
                     [ String
    "pure (.) <*> u <*> v <*> w", String
    congruent, String
    "u <*> (v <*> w), where"
                     , String
    "u = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    showU
                     , String
    "v = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    showV
                     , String
    "w = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    showW
                     ]
            , lawContextReduced :: String
    lawContextReduced = f Integer -> f Integer -> String
    forall a. Show a => a -> a -> String
    reduced f Integer
    lhs f Integer
    rhs
            }

      f Integer -> f Integer -> Context -> PropertyT IO ()
    forall (m :: * -> *) a (f :: * -> *).
    (MonadTest m, HasCallStack, Eq a, Show a,
     forall x. Eq x => Eq (f x), forall x. Show x => Show (f x)) =>
    f a -> f a -> Context -> m ()
    heqCtx1 f Integer
    lhs f Integer
    rhs Context
    ctx

    applicativeHomomorphism :: forall f. ApplicativeProp f
    applicativeHomomorphism :: forall (f :: * -> *). ApplicativeProp f
    applicativeHomomorphism forall x. Gen x -> Gen (f x)
    _ = HasCallStack => PropertyT IO () -> Property
    PropertyT IO () -> Property
    property (PropertyT IO () -> Property) -> PropertyT IO () -> Property
    forall a b. (a -> b) -> a -> b
    $ do
      QuadraticEquation
    e <- Gen QuadraticEquation -> PropertyT IO QuadraticEquation
    forall (m :: * -> *) a.
    (Monad m, Show a, HasCallStack) =>
    Gen a -> PropertyT m a
    forAll Gen QuadraticEquation
    genQuadraticEquation
      Integer
    a <- Gen Integer -> PropertyT IO Integer
    forall (m :: * -> *) a.
    (Monad m, Show a, HasCallStack) =>
    Gen a -> PropertyT m a
    forAll Gen Integer
    genSmallInteger
      let f :: Integer -> Integer
    f = QuadraticEquation -> Integer -> Integer
    runQuadraticEquation QuadraticEquation
    e
      let lhs :: f Integer
    lhs = (Integer -> Integer) -> f (Integer -> Integer)
    forall a. a -> f a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Integer -> Integer
    f f (Integer -> Integer) -> f Integer -> f Integer
    forall a b. f (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Integer -> f Integer
    forall a. a -> f a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Integer
    a
      let rhs :: f Integer
    rhs = Integer -> f Integer
    forall a. a -> f a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (Integer -> Integer
    f Integer
    a) :: f Integer
      let ctx :: Context
    ctx = LawContext -> Context
    contextualise (LawContext -> Context) -> LawContext -> Context
    forall a b. (a -> b) -> a -> b
    $ LawContext
            { lawContextLawName :: String
    lawContextLawName = String
    "Homomorphism", lawContextLawBody :: String
    lawContextLawBody = String
    "pure f <*> pure x" String -> String -> String
    `congruency` String
    "pure (f x)"
            , lawContextTcName :: String
    lawContextTcName = String
    "Applicative", lawContextTcProp :: String
    lawContextTcProp =
                let showF :: String
    showF = QuadraticEquation -> String
    forall a. Show a => a -> String
    show QuadraticEquation
    e; showX :: String
    showX = Integer -> String
    forall a. Show a => a -> String
    show Integer
    a;
                in [String] -> String
    lawWhere
                  [ String
    "pure f <*> pure x", String
    congruent, String
    "pure (f x), where"
                  , String
    "f = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    showF
                  , String
    "x = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    showX
                  ]
            , lawContextReduced :: String
    lawContextReduced = f Integer -> f Integer -> String
    forall a. Show a => a -> a -> String
    reduced f Integer
    lhs f Integer
    rhs
            }
      f Integer -> f Integer -> Context -> PropertyT IO ()
    forall (m :: * -> *) a (f :: * -> *).
    (MonadTest m, HasCallStack, Eq a, Show a,
     forall x. Eq x => Eq (f x), forall x. Show x => Show (f x)) =>
    f a -> f a -> Context -> m ()
    heqCtx1 f Integer
    lhs f Integer
    rhs Context
    ctx

    applicativeInterchange :: forall f. ApplicativeProp f
    applicativeInterchange :: forall (f :: * -> *). ApplicativeProp f
    applicativeInterchange forall x. Gen x -> Gen (f x)
    fgen = HasCallStack => PropertyT IO () -> Property
    PropertyT IO () -> Property
    property (PropertyT IO () -> Property) -> PropertyT IO () -> Property
    forall a b. (a -> b) -> a -> b
    $ do
      f QuadraticEquation
    u' <- Gen (f QuadraticEquation) -> PropertyT IO (f QuadraticEquation)
    forall (m :: * -> *) a.
    (Monad m, Show a, HasCallStack) =>
    Gen a -> PropertyT m a
    forAll (Gen (f QuadraticEquation) -> PropertyT IO (f QuadraticEquation))
    -> Gen (f QuadraticEquation) -> PropertyT IO (f QuadraticEquation)
    forall a b. (a -> b) -> a -> b
    $ Gen QuadraticEquation -> Gen (f QuadraticEquation)
    forall x. Gen x -> Gen (f x)
    fgen Gen QuadraticEquation
    genQuadraticEquation
      Integer
    y <- Gen Integer -> PropertyT IO Integer
    forall (m :: * -> *) a.
    (Monad m, Show a, HasCallStack) =>
    Gen a -> PropertyT m a
    forAll Gen Integer
    genSmallInteger
      let u :: f (Integer -> Integer)
    u = (QuadraticEquation -> Integer -> Integer)
    -> f QuadraticEquation -> f (Integer -> Integer)
    forall a b. (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap QuadraticEquation -> Integer -> Integer
    runQuadraticEquation f QuadraticEquation
    u'
      let lhs :: f Integer
    lhs = (f (Integer -> Integer)
    u f (Integer -> Integer) -> f Integer -> f Integer
    forall a b. f (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Integer -> f Integer
    forall a. a -> f a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Integer
    y)
      let rhs :: f Integer
    rhs = ((Integer -> Integer) -> Integer)
    -> f ((Integer -> Integer) -> Integer)
    forall a. a -> f a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ((Integer -> Integer) -> Integer -> Integer
    forall a b. (a -> b) -> a -> b
    $ Integer
    y) f ((Integer -> Integer) -> Integer)
    -> f (Integer -> Integer) -> f Integer
    forall a b. f (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> f (Integer -> Integer)
    u
      let ctx :: Context
    ctx = LawContext -> Context
    contextualise (LawContext -> Context) -> LawContext -> Context
    forall a b. (a -> b) -> a -> b
    $ LawContext
            { lawContextLawName :: String
    lawContextLawName = String
    "Interchange", lawContextLawBody :: String
    lawContextLawBody = String
    "u <*> pure y" String -> String -> String
    `congruency` String
    "pure ($ y) <*> u"
            , lawContextTcName :: String
    lawContextTcName = String
    "Applicative", lawContextTcProp :: String
    lawContextTcProp =
                let showU :: String
    showU = f QuadraticEquation -> String
    forall a. Show a => a -> String
    show f QuadraticEquation
    u'; showY :: String
    showY = Integer -> String
    forall a. Show a => a -> String
    show Integer
    y;
                in [String] -> String
    lawWhere
                  [ String
    "u <*> pure y", String
    congruent, String
    "pure ($ y) <*> u, where"
                  , String
    "u = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    showU
                  , String
    "y = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    showY
                  ]
            , lawContextReduced :: String
    lawContextReduced = f Integer -> f Integer -> String
    forall a. Show a => a -> a -> String
    reduced f Integer
    lhs f Integer
    rhs
            }
      f Integer -> f Integer -> Context -> PropertyT IO ()
    forall (m :: * -> *) a (f :: * -> *).
    (MonadTest m, HasCallStack, Eq a, Show a,
     forall x. Eq x => Eq (f x), forall x. Show x => Show (f x)) =>
    f a -> f a -> Context -> m ()
    heqCtx1 f Integer
    lhs f Integer
    rhs Context
    ctx

    applicativeLiftA2_1 :: forall f. ApplicativeProp f
    applicativeLiftA2_1 :: forall (f :: * -> *). ApplicativeProp f
    applicativeLiftA2_1 forall x. Gen x -> Gen (f x)
    fgen = HasCallStack => PropertyT IO () -> Property
    PropertyT IO () -> Property
    property (PropertyT IO () -> Property) -> PropertyT IO () -> Property
    forall a b. (a -> b) -> a -> b
    $ do
      f QuadraticEquation
    f' <- Gen (f QuadraticEquation) -> PropertyT IO (f QuadraticEquation)
    forall (m :: * -> *) a.
    (Monad m, Show a, HasCallStack) =>
    Gen a -> PropertyT m a
    forAll (Gen (f QuadraticEquation) -> PropertyT IO (f QuadraticEquation))
    -> Gen (f QuadraticEquation) -> PropertyT IO (f QuadraticEquation)
    forall a b. (a -> b) -> a -> b
    $ Gen QuadraticEquation -> Gen (f QuadraticEquation)
    forall x. Gen x -> Gen (f x)
    fgen Gen QuadraticEquation
    genQuadraticEquation
      f Integer
    x <- Gen (f Integer) -> PropertyT IO (f Integer)
    forall (m :: * -> *) a.
    (Monad m, Show a, HasCallStack) =>
    Gen a -> PropertyT m a
    forAll (Gen (f Integer) -> PropertyT IO (f Integer))
    -> Gen (f Integer) -> PropertyT IO (f Integer)
    forall a b. (a -> b) -> a -> b
    $ Gen Integer -> Gen (f Integer)
    forall x. Gen x -> Gen (f x)
    fgen Gen Integer
    genSmallInteger
      let f :: f (Integer -> Integer)
    f = (QuadraticEquation -> Integer -> Integer)
    -> f QuadraticEquation -> f (Integer -> Integer)
    forall a b. (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap QuadraticEquation -> Integer -> Integer
    runQuadraticEquation f QuadraticEquation
    f'
      let lhs :: f Integer
    lhs = ((Integer -> Integer) -> Integer -> Integer)
    -> f (Integer -> Integer) -> f Integer -> f Integer
    forall a b c. (a -> b -> c) -> f a -> f b -> f c
    forall (f :: * -> *) a b c.
    Applicative f =>
    (a -> b -> c) -> f a -> f b -> f c
    liftA2 (Integer -> Integer) -> Integer -> Integer
    forall a. a -> a
    id f (Integer -> Integer)
    f f Integer
    x
      let rhs :: f Integer
    rhs = f (Integer -> Integer)
    f f (Integer -> Integer) -> f Integer -> f Integer
    forall a b. f (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> f Integer
    x
      let ctx :: Context
    ctx = LawContext -> Context
    contextualise (LawContext -> Context) -> LawContext -> Context
    forall a b. (a -> b) -> a -> b
    $ LawContext
            { lawContextLawName :: String
    lawContextLawName = String
    "LiftA2 1", lawContextLawBody :: String
    lawContextLawBody = String
    "liftA2 id f x" String -> String -> String
    `congruency` String
    "f <*> x"
            , lawContextTcName :: String
    lawContextTcName = String
    "Applicative", lawContextTcProp :: String
    lawContextTcProp =
                let showF :: String
    showF = f QuadraticEquation -> String
    forall a. Show a => a -> String
    show f QuadraticEquation
    f'; showX :: String
    showX = f Integer -> String
    forall a. Show a => a -> String
    show f Integer
    x;
                in [String] -> String
    lawWhere
                  [ String
    "liftA2 id f x", String
    congruent, String
    "f <*> x, where"
                  , String
    "f = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    showF
                  , String
    "x = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    showX
                  ]
            , lawContextReduced :: String
    lawContextReduced = f Integer -> f Integer -> String
    forall a. Show a => a -> a -> String
    reduced f Integer
    lhs f Integer
    rhs
            }
      f Integer -> f Integer -> Context -> PropertyT IO ()
    forall (m :: * -> *) a (f :: * -> *).
    (MonadTest m, HasCallStack, Eq a, Show a,
     forall x. Eq x => Eq (f x), forall x. Show x => Show (f x)) =>
    f a -> f a -> Context -> m ()
    heqCtx1 f Integer
    lhs f Integer
    rhs Context
    ctx

    applicativeLiftA2_2 :: forall f. ApplicativeProp f
    applicativeLiftA2_2 :: forall (f :: * -> *). ApplicativeProp f
    applicativeLiftA2_2 forall x. Gen x -> Gen (f x)
    fgen = HasCallStack => PropertyT IO () -> Property
    PropertyT IO () -> Property
    property (PropertyT IO () -> Property) -> PropertyT IO () -> Property
    forall a b. (a -> b) -> a -> b
    $ do
      f Integer
    x <- Gen (f Integer) -> PropertyT IO (f Integer)
    forall (m :: * -> *) a.
    (Monad m, Show a, HasCallStack) =>
    Gen a -> PropertyT m a
    forAll (Gen (f Integer) -> PropertyT IO (f Integer))
    -> Gen (f Integer) -> PropertyT IO (f Integer)
    forall a b. (a -> b) -> a -> b
    $ Gen Integer -> Gen (f Integer)
    forall x. Gen x -> Gen (f x)
    fgen Gen Integer
    genSmallInteger
      f Integer
    y <- Gen (f Integer) -> PropertyT IO (f Integer)
    forall (m :: * -> *) a.
    (Monad m, Show a, HasCallStack) =>
    Gen a -> PropertyT m a
    forAll (Gen (f Integer) -> PropertyT IO (f Integer))
    -> Gen (f Integer) -> PropertyT IO (f Integer)
    forall a b. (a -> b) -> a -> b
    $ Gen Integer -> Gen (f Integer)
    forall x. Gen x -> Gen (f x)
    fgen Gen Integer
    genSmallInteger
      LinearEquationTwo
    f' <- Gen LinearEquationTwo -> PropertyT IO LinearEquationTwo
    forall (m :: * -> *) a.
    (Monad m, Show a, HasCallStack) =>
    Gen a -> PropertyT m a
    forAll (Gen LinearEquationTwo -> PropertyT IO LinearEquationTwo)
    -> Gen LinearEquationTwo -> PropertyT IO LinearEquationTwo
    forall a b. (a -> b) -> a -> b
    $ Gen LinearEquationTwo
    genLinearEquationTwo
      let f :: Integer -> Integer -> Integer
    f = LinearEquationTwo -> Integer -> Integer -> Integer
    runLinearEquationTwo LinearEquationTwo
    f'
      let lhs :: f Integer
    lhs = (Integer -> Integer -> Integer)
    -> f Integer -> f Integer -> f Integer
    forall a b c. (a -> b -> c) -> f a -> f b -> f c
    forall (f :: * -> *) a b c.
    Applicative f =>
    (a -> b -> c) -> f a -> f b -> f c
    liftA2 Integer -> Integer -> Integer
    f f Integer
    x f Integer
    y
      let rhs :: f Integer
    rhs = Integer -> Integer -> Integer
    f (Integer -> Integer -> Integer)
    -> f Integer -> f (Integer -> Integer)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> f Integer
    x f (Integer -> Integer) -> f Integer -> f Integer
    forall a b. f (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> f Integer
    y
      let ctx :: Context
    ctx = LawContext -> Context
    contextualise (LawContext -> Context) -> LawContext -> Context
    forall a b. (a -> b) -> a -> b
    $ LawContext
            { lawContextLawName :: String
    lawContextLawName = String
    "LiftA2 2", lawContextLawBody :: String
    lawContextLawBody = String
    "liftA2 f x y == f <$> x <*> y"
            , lawContextTcName :: String
    lawContextTcName = String
    "Applicative", lawContextTcProp :: String
    lawContextTcProp =
                let showF :: String
    showF = LinearEquationTwo -> String
    forall a. Show a => a -> String
    show LinearEquationTwo
    f'; showX :: String
    showX = f Integer -> String
    forall a. Show a => a -> String
    show f Integer
    x; showY :: String
    showY = f Integer -> String
    forall a. Show a => a -> String
    show f Integer
    y;
                in [String] -> String
    lawWhere
                  [ String
    "liftA2 f x y" String -> String -> String
    `congruency` String
    "f <$> x <*> y, where"
                  , String
    "f = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    showF
                  , String
    "x = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    showX
                  , String
    "y = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    showY
                  ]
            , lawContextReduced :: String
    lawContextReduced = f Integer -> f Integer -> String
    forall a. Show a => a -> a -> String
    reduced f Integer
    lhs f Integer
    rhs
            }
      f Integer -> f Integer -> Context -> PropertyT IO ()
    forall (m :: * -> *) a (f :: * -> *).
    (MonadTest m, HasCallStack, Eq a, Show a,
     forall x. Eq x => Eq (f x), forall x. Show x => Show (f x)) =>
    f a -> f a -> Context -> m ()
    heqCtx1 f Integer
    lhs f Integer
    rhs Context
    ctx