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

import Data.Proxy
import Test.QuickCheck
import Test.QuickCheck.Classes
import qualified Data.HashMap.Strict as Map
import           Data.HashMap.Strict(HashMap)

-- ~\~ begin <<less-arbitrary.md|arbitrary-laws>>[0]
shrinkCheck :: forall    term.
              (Arbitrary term
              ,Eq        term)
            =>           term
            -> Bool
shrinkCheck :: forall term. (Arbitrary term, Eq term) => term -> Bool
shrinkCheck term
term =
  term
term forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` forall a. Arbitrary a => a -> [a]
shrink term
term

arbitraryLaws :: forall    ty.
                (Arbitrary ty
                ,Show      ty
                ,Eq        ty)
              => Proxy     ty
              -> Laws
arbitraryLaws :: forall ty. (Arbitrary ty, Show ty, Eq ty) => Proxy ty -> Laws
arbitraryLaws (Proxy ty
Proxy :: Proxy ty) =
  String -> [(String, Property)] -> Laws
Laws String
"arbitrary"
       [(String
"does not shrink to itself",
         forall prop. Testable prop => prop -> Property
property (forall term. (Arbitrary term, Eq term) => term -> Bool
shrinkCheck :: ty -> Bool))]
-- ~\~ end
-- ~\~ end