{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Test.QuickCheck.Instances.Scientific () where
import Prelude ()
import Test.QuickCheck.Instances.CustomPrelude
import Test.QuickCheck
import qualified Data.Scientific as Scientific
instance Arbitrary Scientific.Scientific where
arbitrary :: Gen Scientific
arbitrary = do
Integer
c <- forall a. Arbitrary a => Gen a
arbitrary
Int
e <- forall a. Arbitrary a => Gen a
arbitrary
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Integer -> Int -> Scientific
Scientific.scientific Integer
c Int
e
shrink :: Scientific -> [Scientific]
shrink Scientific
s = forall a b. (a -> b) -> [a] -> [b]
map (forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Integer -> Int -> Scientific
Scientific.scientific) forall a b. (a -> b) -> a -> b
$
forall a. Arbitrary a => a -> [a]
shrink (Scientific -> Integer
Scientific.coefficient Scientific
s, Scientific -> Int
Scientific.base10Exponent Scientific
s)
instance CoArbitrary Scientific.Scientific where
coarbitrary :: forall b. Scientific -> Gen b -> Gen b
coarbitrary Scientific
s = forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary (Scientific -> Integer
Scientific.coefficient Scientific
s, Scientific -> Int
Scientific.base10Exponent Scientific
s)
instance Function Scientific.Scientific where
function :: forall b. (Scientific -> b) -> Scientific :-> b
function = forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap
(\Scientific
s -> (Scientific -> Integer
Scientific.coefficient Scientific
s, Scientific -> Int
Scientific.base10Exponent Scientific
s))
(forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Integer -> Int -> Scientific
Scientific.scientific)