module Test.QuickCheck.Extras (
    sized1
  , unsafeMapSuchThatJust
  ) where

import qualified Test.QuickCheck as QC

sized1 :: (Int -> QC.Gen a) -> QC.Gen a
sized1 :: forall a. (Int -> Gen a) -> Gen a
sized1 Int -> Gen a
f = (Int -> Gen a) -> Gen a
forall a. (Int -> Gen a) -> Gen a
QC.sized (Int -> Gen a
f (Int -> Gen a) -> (Int -> Int) -> Int -> Gen a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Int
forall a. Enum a => a -> a
succ)

-- | A generator that checks its own satisfaction
--
-- WARNING: 'QC.suchThat' et al often causes a /very/ confusing
-- non-termination when its argument is impossible/extremely unlikely
unsafeMapSuchThatJust :: QC.Gen (Maybe a) -> QC.Gen a
unsafeMapSuchThatJust :: forall a. Gen (Maybe a) -> Gen a
unsafeMapSuchThatJust Gen (Maybe a)
m = Gen (Maybe a) -> (Maybe a -> Maybe a) -> Gen a
forall a b. Gen a -> (a -> Maybe b) -> Gen b
QC.suchThatMap Gen (Maybe a)
m Maybe a -> Maybe a
forall a. a -> a
id