{-# OPTIONS_GHC -fno-warn-orphans #-}
module Data.HashSet.Arbitrary where

import Data.Hashable (Hashable)
import Data.HashSet (HashSet)
import Test.QuickCheck (Arbitrary(..))
import qualified Data.HashSet

instance (Hashable a, Eq a, Arbitrary a) => Arbitrary (HashSet a) where
  arbitrary :: Gen (HashSet a)
arbitrary = [a] -> HashSet a
forall a. (Eq a, Hashable a) => [a] -> HashSet a
Data.HashSet.fromList ([a] -> HashSet a) -> Gen [a] -> Gen (HashSet a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen [a]
forall a. Arbitrary a => Gen a
arbitrary
  shrink :: HashSet a -> [HashSet a]
shrink HashSet a
hashset = [a] -> HashSet a
forall a. (Eq a, Hashable a) => [a] -> HashSet a
Data.HashSet.fromList ([a] -> HashSet a) -> [[a]] -> [HashSet a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [a] -> [[a]]
forall a. Arbitrary a => a -> [a]
shrink (HashSet a -> [a]
forall a. HashSet a -> [a]
Data.HashSet.toList HashSet a
hashset)