{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Test.QuickCheck.Instances.UnorderedContainers () where
import Prelude ()
import Test.QuickCheck.Instances.CustomPrelude
import Data.Hashable (Hashable)
import Test.QuickCheck
import qualified Data.HashMap.Lazy as HML
import qualified Data.HashSet as HS
instance (Hashable a, Eq a, Arbitrary a) => Arbitrary (HS.HashSet a) where
arbitrary :: Gen (HashSet a)
arbitrary = forall a. (Eq a, Hashable a) => [a] -> HashSet a
HS.fromList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => Gen a
arbitrary
shrink :: HashSet a -> [HashSet a]
shrink HashSet a
hashset = forall a. (Eq a, Hashable a) => [a] -> HashSet a
HS.fromList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Arbitrary a => a -> [a]
shrink (forall a. HashSet a -> [a]
HS.toList HashSet a
hashset)
instance CoArbitrary a => CoArbitrary (HS.HashSet a) where
coarbitrary :: forall b. HashSet a -> Gen b -> Gen b
coarbitrary = forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. HashSet a -> [a]
HS.toList
instance (Hashable a, Eq a, Function a) => Function (HS.HashSet a) where
function :: forall b. (HashSet a -> b) -> HashSet a :-> b
function = forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap forall a. HashSet a -> [a]
HS.toList forall a. (Eq a, Hashable a) => [a] -> HashSet a
HS.fromList
instance (Hashable k, Eq k, Arbitrary k) => Arbitrary1 (HML.HashMap k) where
liftArbitrary :: forall a. Gen a -> Gen (HashMap k a)
liftArbitrary Gen a
arb =
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HML.fromList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) a. Arbitrary1 f => Gen a -> Gen (f a)
liftArbitrary (forall (f :: * -> * -> *) a b.
Arbitrary2 f =>
Gen a -> Gen b -> Gen (f a b)
liftArbitrary2 forall a. Arbitrary a => Gen a
arbitrary Gen a
arb)
liftShrink :: forall a. (a -> [a]) -> HashMap k a -> [HashMap k a]
liftShrink a -> [a]
shr HashMap k a
m =
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HML.fromList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) a. Arbitrary1 f => (a -> [a]) -> f a -> [f a]
liftShrink (forall (f :: * -> * -> *) a b.
Arbitrary2 f =>
(a -> [a]) -> (b -> [b]) -> f a b -> [f a b]
liftShrink2 forall a. Arbitrary a => a -> [a]
shrink a -> [a]
shr) (forall k v. HashMap k v -> [(k, v)]
HML.toList HashMap k a
m)
instance (Hashable k, Eq k, Arbitrary k, Arbitrary v) => Arbitrary (HML.HashMap k v) where
arbitrary :: Gen (HashMap k v)
arbitrary = forall (f :: * -> *) a. (Arbitrary1 f, Arbitrary a) => Gen (f a)
arbitrary1
shrink :: HashMap k v -> [HashMap k v]
shrink = forall (f :: * -> *) a. (Arbitrary1 f, Arbitrary a) => f a -> [f a]
shrink1
instance (CoArbitrary k, CoArbitrary v) => CoArbitrary (HML.HashMap k v) where
coarbitrary :: forall b. HashMap k v -> Gen b -> Gen b
coarbitrary = forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k v. HashMap k v -> [(k, v)]
HML.toList
instance (Hashable k, Eq k, Function k, Function v) => Function (HML.HashMap k v) where
function :: forall b. (HashMap k v -> b) -> HashMap k v :-> b
function = forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap forall k v. HashMap k v -> [(k, v)]
HML.toList forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HML.fromList