module Test.QuickCheck.Gen.Faker
( fakeQuickcheck'
, fakeQuickcheck
)
where
import Faker
import System.IO.Unsafe (unsafePerformIO)
import System.Random (mkStdGen)
import qualified Test.QuickCheck as Q
fakeQuickcheck :: Fake a -> Q.Gen a
fakeQuickcheck :: Fake a -> Gen a
fakeQuickcheck = FakerSettings -> Fake a -> Gen a
forall a. FakerSettings -> Fake a -> Gen a
fakeQuickcheck' FakerSettings
defaultFakerSettings
fakeQuickcheck' :: FakerSettings -> Fake a -> Q.Gen a
fakeQuickcheck' :: FakerSettings -> Fake a -> Gen a
fakeQuickcheck' FakerSettings
fakerSettings Fake a
f = do
StdGen
randomGen <- Int -> StdGen
mkStdGen (Int -> StdGen) -> Gen Int -> Gen StdGen
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Int, Int) -> Gen Int
forall a. Random a => (a, a) -> Gen a
Q.choose (Int
forall a. Bounded a => a
minBound, Int
forall a. Bounded a => a
maxBound)
a -> Gen a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> Gen a) -> a -> Gen a
forall a b. (a -> b) -> a -> b
$!
IO a -> a
forall a. IO a -> a
unsafePerformIO (IO a -> a) -> IO a -> a
forall a b. (a -> b) -> a -> b
$
FakerSettings -> Fake a -> IO a
forall (m :: * -> *) a.
MonadIO m =>
FakerSettings -> FakeT m a -> m a
Faker.generateWithSettings
(StdGen -> FakerSettings -> FakerSettings
Faker.setRandomGen
StdGen
randomGen
FakerSettings
fakerSettings
)
Fake a
f