    -- Author: Bertram Felgenhauer
    -- License: MIT

    {-# OPTIONS_GHC -fno-full-laziness #-}
    {-# LANGUAGE Trustworthy #-}

    module Test.QuickCheck.Safe.Trusted (
        pureEvaluate, AnException,
        inventQCGen, QCGen
    ) where

    import Test.QuickCheck.Exception
    import Test.QuickCheck.Random
    import System.IO.Unsafe

    -- | 'pureEvaluate' wraps 'Test.QuickCheck.Exception.tryEvaluate' in
    -- 'System.IO.Unsafe.unsafePerformIO'. This may look like a dirty hack,
    -- but this building block allows us to implement most of QuickCheck's
    -- functionality without resorting to IO again.
    pureEvaluate :: a -> Either AnException a
    pureEvaluate :: forall a. a -> Either AnException a
    pureEvaluate = IO (Either AnException a) -> Either AnException a
    forall a. IO a -> a
    unsafePerformIO (IO (Either AnException a) -> Either AnException a)
    -> (a -> IO (Either AnException a)) -> a -> Either AnException a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> IO (Either AnException a)
    forall a. a -> IO (Either AnException a)
    tryEvaluate

    -- | 'inventQCGen' invokes 'Test.QuickCheck.Random.newQCGen' via
    -- 'unsafePerformIO'. It is useful in connection with the
    -- 'Test.QuickCheck.Safe.quickCheck' family of functions.
    {-# NOINLINE inventQCGen #-}
    inventQCGen :: a -> QCGen
    inventQCGen :: forall a. a -> QCGen
    inventQCGen a
    _ = IO QCGen -> QCGen
    forall a. IO a -> a
    unsafePerformIO IO QCGen
    newQCGen