-- ~\~ language=Haskell filename=src/Test/LessArbitrary/Laws.hs
-- ~\~ begin <<less-arbitrary.md|src/Test/LessArbitrary/Laws.hs>>[0]
{-# language DataKinds             #-}
{-# language FlexibleInstances     #-}
{-# language Rank2Types            #-}
{-# language MultiParamTypeClasses #-}
{-# language ScopedTypeVariables   #-}
{-# language TypeOperators         #-}
{-# language UndecidableInstances  #-}
{-# language AllowAmbiguousTypes   #-}
module Test.LessArbitrary.Laws(
      lessArbitraryLaws
    ) where

import Data.Proxy
import Test.QuickCheck(Gen, property)
import Test.QuickCheck.Classes(Laws(..))
import Test.LessArbitrary
import qualified Data.HashMap.Strict as Map
import           Data.HashMap.Strict(HashMap)

-- ~\~ begin <<less-arbitrary.md|less-arbitrary-laws>>[0]
lessArbitraryLaws :: LessArbitrary a
                  => (a -> Bool) -> Laws
lessArbitraryLaws :: (a -> Bool) -> Laws
lessArbitraryLaws a -> Bool
cheapestPred =
    String -> [(String, Property)] -> Laws
Laws String
"LessArbitrary"
         [(String
"always selects cheapest",
           Gen Bool -> Property
forall prop. Testable prop => prop -> Property
property (Gen Bool -> Property) -> Gen Bool -> Property
forall a b. (a -> b) -> a -> b
$
             (a -> Bool) -> Gen Bool
forall a. LessArbitrary a => (a -> Bool) -> Gen Bool
prop_alwaysCheapest a -> Bool
cheapestPred)]

prop_alwaysCheapest :: LessArbitrary a
                    => (a -> Bool) -> Gen Bool
prop_alwaysCheapest :: (a -> Bool) -> Gen Bool
prop_alwaysCheapest a -> Bool
cheapestPred =
  a -> Bool
cheapestPred (a -> Bool) -> Gen a -> Gen Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> CostGen a -> Gen a
forall a. Int -> CostGen a -> Gen a
withCost Int
0 CostGen a
forall a. LessArbitrary a => CostGen a
lessArbitrary
-- ~\~ end
-- ~\~ end