    {-# LANGUAGE CPP #-}
    {-# LANGUAGE ScopedTypeVariables #-}

    {-# OPTIONS_GHC -Wall #-}

    module Test.QuickCheck.Classes.Semiring
      (
    #if HAVE_SEMIRINGS
        semiringLaws
    #endif
      ) where

    #if HAVE_SEMIRINGS
    import Data.Semiring hiding (fromInteger)
    import Prelude hiding (Num(..))
    import Prelude (fromInteger)
    #endif

    import Data.Proxy (Proxy)
    import Test.QuickCheck hiding ((.&.))
    import Test.QuickCheck.Property (Property)

    import Test.QuickCheck.Classes.Internal (Laws(..), myForAllShrink)

    #if HAVE_SEMIRINGS
    -- | Tests the following properties:
    --
    -- [/Additive Commutativity/]
    --   @a + b ≡ b + a@
    -- [/Additive Left Identity/]
    --   @0 + a ≡ a@
    -- [/Additive Right Identity/]
    --   @a + 0 ≡ a@
    -- [/Multiplicative Associativity/]
    --   @a * (b * c) ≡ (a * b) * c@
    -- [/Multiplicative Left Identity/]
    --   @1 * a ≡ a@
    -- [/Multiplicative Right Identity/]
    --   @a * 1 ≡ a@
    -- [/Multiplication Left Distributes Over Addition/]
    --   @a * (b + c) ≡ (a * b) + (a * c)@
    -- [/Multiplication Right Distributes Over Addition/]
    --   @(a + b) * c ≡ (a * c) + (b * c)@
    -- [/Multiplicative Left Annihilation/]
    --   @0 * a ≡ 0@
    -- [/Multiplicative Right Annihilation/]
    --   @a * 0 ≡ 0@
    --
    -- Also tests that 'fromNatural' is a homomorphism of semirings:
    --
    -- [/FromNatural Maps Zero/]
    --   'fromNatural' 0 = 'zero'
    -- [/FromNatural Maps One/]
    --   'fromNatural' 1 = 'one'
    -- [/FromNatural Maps Plus/]
    --   'fromNatural' (@a@ + @b@) = 'fromNatural' @a@ + 'fromNatural' @b@
    -- [/FromNatural Maps Times/]
    --   'fromNatural' (@a@ * @b@) = 'fromNatural' @a@ * 'fromNatural' @b@
    semiringLaws :: (Semiring a, Eq a, Arbitrary a, Show a) => Proxy a -> Laws
    semiringLaws :: forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Laws
    semiringLaws Proxy a
    p = String -> [(String, Property)] -> Laws
    Laws String
    "Semiring"
      [ (String
    "Additive Commutativity", Proxy a -> Property
    forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringCommutativePlus Proxy a
    p)
      , (String
    "Additive Left Identity", Proxy a -> Property
    forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringLeftIdentityPlus Proxy a
    p)
      , (String
    "Additive Right Identity", Proxy a -> Property
    forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringRightIdentityPlus Proxy a
    p)
      , (String
    "Multiplicative Associativity", Proxy a -> Property
    forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringAssociativeTimes Proxy a
    p)
      , (String
    "Multiplicative Left Identity", Proxy a -> Property
    forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringLeftIdentityTimes Proxy a
    p)
      , (String
    "Multiplicative Right Identity", Proxy a -> Property
    forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringRightIdentityTimes Proxy a
    p)
      , (String
    "Multiplication Left Distributes Over Addition", Proxy a -> Property
    forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringLeftMultiplicationDistributes Proxy a
    p)
      , (String
    "Multiplication Right Distributes Over Addition", Proxy a -> Property
    forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringRightMultiplicationDistributes Proxy a
    p)
      , (String
    "Multiplicative Left Annihilation", Proxy a -> Property
    forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringLeftAnnihilation Proxy a
    p)
      , (String
    "Multiplicative Right Annihilation", Proxy a -> Property
    forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringRightAnnihilation Proxy a
    p)
      , (String
    "FromNatural Maps Zero", Proxy a -> Property
    forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringFromNaturalMapsZero Proxy a
    p)
      , (String
    "FromNatural Maps One", Proxy a -> Property
    forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringFromNaturalMapsOne Proxy a
    p)
      , (String
    "FromNatural Maps Plus", Proxy a -> Property
    forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringFromNaturalMapsPlus Proxy a
    p)
      , (String
    "FromNatural Maps Times", Proxy a -> Property
    forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringFromNaturalMapsTimes Proxy a
    p)
      ]

    semiringLeftMultiplicationDistributes :: forall a. (Semiring a, Eq a, Arbitrary a, Show a) => Proxy a -> Property
    semiringLeftMultiplicationDistributes :: forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringLeftMultiplicationDistributes Proxy a
    _ = Bool
    -> ((a, a, a) -> Bool)
    -> ((a, a, a) -> [String])
    -> String
    -> ((a, a, a) -> a)
    -> String
    -> ((a, a, a) -> a)
    -> Property
    forall a b.
    (Arbitrary a, Show b, Eq b) =>
    Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> b)
    -> String
    -> (a -> b)
    -> Property
    myForAllShrink Bool
    True (Bool -> (a, a, a) -> Bool
    forall a b. a -> b -> a
    const Bool
    True)
      (\(a
    a :: a,a
    b,a
    c) -> [String
    "a = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    a, String
    "b = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    b, String
    "c = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    c])
      String
    "a * (b + c)"
      (\(a
    a,a
    b,a
    c) -> a
    a a -> a -> a
    forall a. Semiring a => a -> a -> a
    * (a
    b a -> a -> a
    forall a. Semiring a => a -> a -> a
    + a
    c))
      String
    "(a * b) + (a * c)"
      (\(a
    a,a
    b,a
    c) -> (a
    a a -> a -> a
    forall a. Semiring a => a -> a -> a
    * a
    b) a -> a -> a
    forall a. Semiring a => a -> a -> a
    + (a
    a a -> a -> a
    forall a. Semiring a => a -> a -> a
    * a
    c))

    semiringRightMultiplicationDistributes :: forall a. (Semiring a, Eq a, Arbitrary a, Show a) => Proxy a -> Property
    semiringRightMultiplicationDistributes :: forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringRightMultiplicationDistributes Proxy a
    _ = Bool
    -> ((a, a, a) -> Bool)
    -> ((a, a, a) -> [String])
    -> String
    -> ((a, a, a) -> a)
    -> String
    -> ((a, a, a) -> a)
    -> Property
    forall a b.
    (Arbitrary a, Show b, Eq b) =>
    Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> b)
    -> String
    -> (a -> b)
    -> Property
    myForAllShrink Bool
    True (Bool -> (a, a, a) -> Bool
    forall a b. a -> b -> a
    const Bool
    True)
      (\(a
    a :: a,a
    b,a
    c) -> [String
    "a = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    a, String
    "b = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    b, String
    "c = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    c])
      String
    "(a + b) * c"
      (\(a
    a,a
    b,a
    c) -> (a
    a a -> a -> a
    forall a. Semiring a => a -> a -> a
    + a
    b) a -> a -> a
    forall a. Semiring a => a -> a -> a
    * a
    c)
      String
    "(a * c) + (b * c)"
      (\(a
    a,a
    b,a
    c) -> (a
    a a -> a -> a
    forall a. Semiring a => a -> a -> a
    * a
    c) a -> a -> a
    forall a. Semiring a => a -> a -> a
    + (a
    b a -> a -> a
    forall a. Semiring a => a -> a -> a
    * a
    c))

    semiringLeftIdentityPlus :: forall a. (Semiring a, Eq a, Arbitrary a, Show a) => Proxy a -> Property
    semiringLeftIdentityPlus :: forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringLeftIdentityPlus Proxy a
    _ = Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> a)
    -> String
    -> (a -> a)
    -> Property
    forall a b.
    (Arbitrary a, Show b, Eq b) =>
    Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> b)
    -> String
    -> (a -> b)
    -> Property
    myForAllShrink Bool
    False (Bool -> a -> Bool
    forall a b. a -> b -> a
    const Bool
    True)
      (\(a
    a :: a) -> [String
    "a = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    a])
      String
    "0 + a"
      (\a
    a -> a
    forall a. Semiring a => a
    zero a -> a -> a
    forall a. Semiring a => a -> a -> a
    + a
    a)
      String
    "a"
      (\a
    a -> a
    a)

    semiringRightIdentityPlus :: forall a. (Semiring a, Eq a, Arbitrary a, Show a) => Proxy a -> Property
    semiringRightIdentityPlus :: forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringRightIdentityPlus Proxy a
    _ = Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> a)
    -> String
    -> (a -> a)
    -> Property
    forall a b.
    (Arbitrary a, Show b, Eq b) =>
    Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> b)
    -> String
    -> (a -> b)
    -> Property
    myForAllShrink Bool
    False (Bool -> a -> Bool
    forall a b. a -> b -> a
    const Bool
    True)
      (\(a
    a :: a) -> [String
    "a = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    a])
      String
    "a + 0"
      (\a
    a -> a
    a a -> a -> a
    forall a. Semiring a => a -> a -> a
    + a
    forall a. Semiring a => a
    zero)
      String
    "a"
      (\a
    a -> a
    a)

    semiringRightIdentityTimes :: forall a. (Semiring a, Eq a, Arbitrary a, Show a) => Proxy a -> Property
    semiringRightIdentityTimes :: forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringRightIdentityTimes Proxy a
    _ = Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> a)
    -> String
    -> (a -> a)
    -> Property
    forall a b.
    (Arbitrary a, Show b, Eq b) =>
    Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> b)
    -> String
    -> (a -> b)
    -> Property
    myForAllShrink Bool
    False (Bool -> a -> Bool
    forall a b. a -> b -> a
    const Bool
    True)
      (\(a
    a :: a) -> [String
    "a = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    a])
      String
    "a * 1"
      (\a
    a -> a
    a a -> a -> a
    forall a. Semiring a => a -> a -> a
    * a
    forall a. Semiring a => a
    one)
      String
    "a"
      (\a
    a -> a
    a)

    semiringLeftIdentityTimes :: forall a. (Semiring a, Eq a, Arbitrary a, Show a) => Proxy a -> Property
    semiringLeftIdentityTimes :: forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringLeftIdentityTimes Proxy a
    _ = Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> a)
    -> String
    -> (a -> a)
    -> Property
    forall a b.
    (Arbitrary a, Show b, Eq b) =>
    Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> b)
    -> String
    -> (a -> b)
    -> Property
    myForAllShrink Bool
    False (Bool -> a -> Bool
    forall a b. a -> b -> a
    const Bool
    True)
      (\(a
    a :: a) -> [String
    "a = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    a])
      String
    "1 * a"
      (\a
    a -> a
    forall a. Semiring a => a
    one a -> a -> a
    forall a. Semiring a => a -> a -> a
    * a
    a)
      String
    "a"
      (\a
    a -> a
    a)

    semiringLeftAnnihilation :: forall a. (Semiring a, Eq a, Arbitrary a, Show a) => Proxy a -> Property
    semiringLeftAnnihilation :: forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringLeftAnnihilation Proxy a
    _ = Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> a)
    -> String
    -> (a -> a)
    -> Property
    forall a b.
    (Arbitrary a, Show b, Eq b) =>
    Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> b)
    -> String
    -> (a -> b)
    -> Property
    myForAllShrink Bool
    False (Bool -> a -> Bool
    forall a b. a -> b -> a
    const Bool
    True)
      (\(a
    a :: a) -> [String
    "a = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    a])
      String
    "0 * a"
      (\a
    a -> a
    forall a. Semiring a => a
    zero a -> a -> a
    forall a. Semiring a => a -> a -> a
    * a
    a)
      String
    "0"
      (\a
    _ -> a
    forall a. Semiring a => a
    zero)

    semiringRightAnnihilation :: forall a. (Semiring a, Eq a, Arbitrary a, Show a) => Proxy a -> Property
    semiringRightAnnihilation :: forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringRightAnnihilation Proxy a
    _ = Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> a)
    -> String
    -> (a -> a)
    -> Property
    forall a b.
    (Arbitrary a, Show b, Eq b) =>
    Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> b)
    -> String
    -> (a -> b)
    -> Property
    myForAllShrink Bool
    False (Bool -> a -> Bool
    forall a b. a -> b -> a
    const Bool
    True)
      (\(a
    a :: a) -> [String
    "a = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    a])
      String
    "a * 0"
      (\a
    a -> a
    a a -> a -> a
    forall a. Semiring a => a -> a -> a
    * a
    forall a. Semiring a => a
    zero)
      String
    "0"
      (\a
    _ -> a
    forall a. Semiring a => a
    zero)

    semiringCommutativePlus :: forall a. (Semiring a, Eq a, Arbitrary a, Show a) => Proxy a -> Property
    semiringCommutativePlus :: forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringCommutativePlus Proxy a
    _ = Bool
    -> ((a, a) -> Bool)
    -> ((a, a) -> [String])
    -> String
    -> ((a, a) -> a)
    -> String
    -> ((a, a) -> a)
    -> Property
    forall a b.
    (Arbitrary a, Show b, Eq b) =>
    Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> b)
    -> String
    -> (a -> b)
    -> Property
    myForAllShrink Bool
    True (Bool -> (a, a) -> Bool
    forall a b. a -> b -> a
    const Bool
    True)
      (\(a
    a :: a,a
    b) -> [String
    "a = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    a, String
    "b = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    b])
      String
    "a + b"
      (\(a
    a,a
    b) -> a
    a a -> a -> a
    forall a. Semiring a => a -> a -> a
    + a
    b)
      String
    "b + a"
      (\(a
    a,a
    b) -> a
    b a -> a -> a
    forall a. Semiring a => a -> a -> a
    + a
    a)

    semiringAssociativeTimes :: forall a. (Semiring a, Eq a, Arbitrary a, Show a) => Proxy a -> Property
    semiringAssociativeTimes :: forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringAssociativeTimes Proxy a
    _ = Bool
    -> ((a, a, a) -> Bool)
    -> ((a, a, a) -> [String])
    -> String
    -> ((a, a, a) -> a)
    -> String
    -> ((a, a, a) -> a)
    -> Property
    forall a b.
    (Arbitrary a, Show b, Eq b) =>
    Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> b)
    -> String
    -> (a -> b)
    -> Property
    myForAllShrink Bool
    True (Bool -> (a, a, a) -> Bool
    forall a b. a -> b -> a
    const Bool
    True)
      (\(a
    a :: a,a
    b,a
    c) -> [String
    "a = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    a, String
    "b = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    b, String
    "c = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ a -> String
    forall a. Show a => a -> String
    show a
    c])
      String
    "a * (b * c)"
      (\(a
    a,a
    b,a
    c) -> a
    a a -> a -> a
    forall a. Semiring a => a -> a -> a
    * (a
    b a -> a -> a
    forall a. Semiring a => a -> a -> a
    * a
    c))
      String
    "(a * b) * c"
      (\(a
    a,a
    b,a
    c) -> (a
    a a -> a -> a
    forall a. Semiring a => a -> a -> a
    * a
    b) a -> a -> a
    forall a. Semiring a => a -> a -> a
    * a
    c)

    semiringFromNaturalMapsZero :: forall a. (Semiring a, Eq a, Arbitrary a, Show a) => Proxy a -> Property
    semiringFromNaturalMapsZero :: forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringFromNaturalMapsZero Proxy a
    _ = Bool
    -> (() -> Bool)
    -> (() -> [String])
    -> String
    -> (() -> a)
    -> String
    -> (() -> a)
    -> Property
    forall a b.
    (Arbitrary a, Show b, Eq b) =>
    Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> b)
    -> String
    -> (a -> b)
    -> Property
    myForAllShrink Bool
    False (Bool -> () -> Bool
    forall a b. a -> b -> a
    const Bool
    True)
      (\()
    _ -> [String
    ""])
      String
    "fromNatural 0"
      (\() -> Natural -> a
    forall a. Semiring a => Natural -> a
    fromNatural Natural
    0 :: a)
      String
    "zero"
      (\() -> a
    forall a. Semiring a => a
    zero)

    semiringFromNaturalMapsOne :: forall a. (Semiring a, Eq a, Arbitrary a, Show a) => Proxy a -> Property
    semiringFromNaturalMapsOne :: forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringFromNaturalMapsOne Proxy a
    _ = Bool
    -> (() -> Bool)
    -> (() -> [String])
    -> String
    -> (() -> a)
    -> String
    -> (() -> a)
    -> Property
    forall a b.
    (Arbitrary a, Show b, Eq b) =>
    Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> b)
    -> String
    -> (a -> b)
    -> Property
    myForAllShrink Bool
    False (Bool -> () -> Bool
    forall a b. a -> b -> a
    const Bool
    True)
      (\()
    _ -> [String
    ""])
      String
    "fromNatural 1"
      (\() -> Natural -> a
    forall a. Semiring a => Natural -> a
    fromNatural Natural
    1 :: a)
      String
    "one"
      (\() -> a
    forall a. Semiring a => a
    one)

    -- | There is no Arbitrary instance for Natural in QuickCheck,
    -- so we use NonNegative Integer instead.
    semiringFromNaturalMapsPlus :: forall a. (Semiring a, Eq a, Arbitrary a, Show a) => Proxy a -> Property
    semiringFromNaturalMapsPlus :: forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringFromNaturalMapsPlus Proxy a
    _ = Bool
    -> ((NonNegative Integer, NonNegative Integer) -> Bool)
    -> ((NonNegative Integer, NonNegative Integer) -> [String])
    -> String
    -> ((NonNegative Integer, NonNegative Integer) -> a)
    -> String
    -> ((NonNegative Integer, NonNegative Integer) -> a)
    -> Property
    forall a b.
    (Arbitrary a, Show b, Eq b) =>
    Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> b)
    -> String
    -> (a -> b)
    -> Property
    myForAllShrink Bool
    True (Bool -> (NonNegative Integer, NonNegative Integer) -> Bool
    forall a b. a -> b -> a
    const Bool
    True)
      (\(NonNegative Integer
    a, NonNegative Integer
    b) -> [String
    "a = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ Integer -> String
    forall a. Show a => a -> String
    show Integer
    a, String
    "b = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ Integer -> String
    forall a. Show a => a -> String
    show Integer
    b])
      String
    "fromNatural (a + b)"
      (\(NonNegative Integer
    a, NonNegative Integer
    b) -> Natural -> a
    forall a. Semiring a => Natural -> a
    fromNatural (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger (Integer
    a Integer -> Integer -> Integer
    forall a. Semiring a => a -> a -> a
    + Integer
    b)) :: a)
      String
    "fromNatural a + fromNatural b"
      (\(NonNegative Integer
    a, NonNegative Integer
    b) -> Natural -> a
    forall a. Semiring a => Natural -> a
    fromNatural (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger Integer
    a) a -> a -> a
    forall a. Semiring a => a -> a -> a
    + Natural -> a
    forall a. Semiring a => Natural -> a
    fromNatural (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger Integer
    b))

    semiringFromNaturalMapsTimes :: forall a. (Semiring a, Eq a, Arbitrary a, Show a) => Proxy a -> Property
    semiringFromNaturalMapsTimes :: forall a.
    (Semiring a, Eq a, Arbitrary a, Show a) =>
    Proxy a -> Property
    semiringFromNaturalMapsTimes Proxy a
    _ = Bool
    -> ((NonNegative Integer, NonNegative Integer) -> Bool)
    -> ((NonNegative Integer, NonNegative Integer) -> [String])
    -> String
    -> ((NonNegative Integer, NonNegative Integer) -> a)
    -> String
    -> ((NonNegative Integer, NonNegative Integer) -> a)
    -> Property
    forall a b.
    (Arbitrary a, Show b, Eq b) =>
    Bool
    -> (a -> Bool)
    -> (a -> [String])
    -> String
    -> (a -> b)
    -> String
    -> (a -> b)
    -> Property
    myForAllShrink Bool
    True (Bool -> (NonNegative Integer, NonNegative Integer) -> Bool
    forall a b. a -> b -> a
    const Bool
    True)
      (\(NonNegative Integer
    a, NonNegative Integer
    b) -> [String
    "a = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ Integer -> String
    forall a. Show a => a -> String
    show Integer
    a, String
    "b = " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ Integer -> String
    forall a. Show a => a -> String
    show Integer
    b])
      String
    "fromNatural (a * b)"
      (\(NonNegative Integer
    a, NonNegative Integer
    b) -> Natural -> a
    forall a. Semiring a => Natural -> a
    fromNatural (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger (Integer
    a Integer -> Integer -> Integer
    forall a. Semiring a => a -> a -> a
    * Integer
    b)) :: a)
      String
    "fromNatural a * fromNatural b"
      (\(NonNegative Integer
    a, NonNegative Integer
    b) -> Natural -> a
    forall a. Semiring a => Natural -> a
    fromNatural (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger Integer
    a) a -> a -> a
    forall a. Semiring a => a -> a -> a
    * Natural -> a
    forall a. Semiring a => Natural -> a
    fromNatural (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger Integer
    b))

    #endif