    {-# OPTIONS_GHC -fno-warn-orphans #-}

    module Data.GenValidity.Map
      ( genMapOf,
        shrinkMapOf,
      )
    where

    import Data.GenValidity
    import Data.Map (Map)
    import qualified Data.Map as M
    import Data.Validity.Map ()
    import Test.QuickCheck

    instance (Show k, Ord k, GenValid k, GenValid v) => GenValid (Map k v) where
      genValid :: Gen (Map k v)
    genValid = Gen (k, v) -> Gen (Map k v)
    forall k v. Ord k => Gen (k, v) -> Gen (Map k v)
    genMapOf Gen (k, v)
    forall a. GenValid a => Gen a
    genValid
      shrinkValid :: Map k v -> [Map k v]
    shrinkValid = ((k, v) -> [(k, v)]) -> Map k v -> [Map k v]
    forall k v. Ord k => ((k, v) -> [(k, v)]) -> Map k v -> [Map k v]
    shrinkMapOf (k, v) -> [(k, v)]
    forall a. GenValid a => a -> [a]
    shrinkValid

    genMapOf :: (Ord k) => Gen (k, v) -> Gen (Map k v)
    genMapOf :: forall k v. Ord k => Gen (k, v) -> Gen (Map k v)
    genMapOf Gen (k, v)
    g = [(k, v)] -> Map k v
    forall k a. Ord k => [(k, a)] -> Map k a
    M.fromList ([(k, v)] -> Map k v) -> Gen [(k, v)] -> Gen (Map k v)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen (k, v) -> Gen [(k, v)]
    forall a. Gen a -> Gen [a]
    genListOf Gen (k, v)
    g

    shrinkMapOf :: (Ord k) => ((k, v) -> [(k, v)]) -> Map k v -> [Map k v]
    shrinkMapOf :: forall k v. Ord k => ((k, v) -> [(k, v)]) -> Map k v -> [Map k v]
    shrinkMapOf (k, v) -> [(k, v)]
    shrinker = ([(k, v)] -> Map k v) -> [[(k, v)]] -> [Map k v]
    forall a b. (a -> b) -> [a] -> [b]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [(k, v)] -> Map k v
    forall k a. Ord k => [(k, a)] -> Map k a
    M.fromList ([[(k, v)]] -> [Map k v])
    -> (Map k v -> [[(k, v)]]) -> Map k v -> [Map k v]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ((k, v) -> [(k, v)]) -> [(k, v)] -> [[(k, v)]]
    forall a. (a -> [a]) -> [a] -> [[a]]
    shrinkList (k, v) -> [(k, v)]
    shrinker ([(k, v)] -> [[(k, v)]])
    -> (Map k v -> [(k, v)]) -> Map k v -> [[(k, v)]]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Map k v -> [(k, v)]
    forall k a. Map k a -> [(k, a)]
    M.toList