    {-# LANGUAGE CPP #-}
    {-# LANGUAGE TypeSynonymInstances #-}
    {-# LANGUAGE FlexibleInstances #-}
    {-# OPTIONS_GHC -fno-warn-orphans #-}
    module Test.QuickCheck.IO where

    import qualified Control.Exception as E
    import           Test.HUnit.Lang
    import           Test.QuickCheck.Property

    instance Testable Assertion where
      property :: Assertion -> Property
    property = Assertion -> Property
    propertyIO
    #if !MIN_VERSION_QuickCheck(2,9,0)
      exhaustive _ = True
    #endif

    propertyIO :: Assertion -> Property
    propertyIO :: Assertion -> Property
    propertyIO Assertion
    action = IO Result -> Property
    forall prop. Testable prop => IO prop -> Property
    ioProperty (IO Result -> Property) -> IO Result -> Property
    forall a b. (a -> b) -> a -> b
    $ do
      (Assertion
    action Assertion -> IO Result -> IO Result
    forall a b. IO a -> IO b -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Result -> IO Result
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Result
    succeeded) IO Result -> (HUnitFailure -> IO Result) -> IO Result
    forall e a. Exception e => IO a -> (e -> IO a) -> IO a
    `E.catch` \ HUnitFailure
    e ->
        Result -> IO Result
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Result
    failed {theException = Just (E.toException e), reason = formatAssertion e}
      where
        formatAssertion :: HUnitFailure -> String
    formatAssertion HUnitFailure
    e = case HUnitFailure
    e of
    #if MIN_VERSION_HUnit(1,3,0)
          HUnitFailure Maybe SrcLoc
    _ FailureReason
    err ->
    #else
          HUnitFailure err ->
    #endif
    #if MIN_VERSION_HUnit(1,5,0)
            FailureReason -> String
    formatFailureReason FailureReason
    err
    #else
            err
    #endif