@@ -18,6 +18,7 @@ module Tests.QuickCheckUtils
1818 , unsquare
1919 , smallArbitrary
2020
21+ , BigInt(..)
2122 , NotEmpty (..)
2223
2324 , Small (..)
@@ -37,6 +38,7 @@ module Tests.QuickCheckUtils
3738 , write_read
3839 ) where
3940
41+import Control.Applicative ((<$>))
4042import Control.Arrow (first, (***))
4143import Control.DeepSeq (NFData (..), deepseq)
4244import Control.Exception (bracket)
@@ -160,6 +162,14 @@ instance Arbitrary TL.Text where
160162 arbitrary = (TL.fromChunks . map notEmpty) `fmap` smallArbitrary
161163 shrink = map TL.pack . shrink . TL.unpack
162164
165+newtype BigInt = Big Integer
166+ deriving (Eq, Show)
167+
168+instance Arbitrary BigInt where
169+ arbitrary = choose (20::Int,200) >>= \e -> Big <$> choose (10^(e-1),10^e)
170+ shrink (Big a) = [Big (a `div` 2^(l-e)) | e <- shrink l]
171+ where l = truncate (log (fromIntegral a) / log 2 :: Double) :: Integer
172+
163173newtype NotEmpty a = NotEmpty { notEmpty :: a }
164174 deriving (Eq, Ord)
165175