Hoogle Search
Within LTS Haskell 24.41 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
isSubmapOf :: (Hashable k, Eq v) => HashMap k v -> HashMap k v -> Boolunordered-containers Data.HashMap.Strict Inclusion of maps. A map is included in another map if the keys are subsets and the corresponding values are equal:
isSubmapOf m1 m2 = keys m1 `isSubsetOf` keys m2 && and [ v1 == v2 | (k1,v1) <- toList m1; let v2 = m2 ! k1 ]
Examples
>>> fromList [(1,'a')] `isSubmapOf` fromList [(1,'a'),(2,'b')] True
>>> fromList [(1,'a'),(2,'b')] `isSubmapOf` fromList [(1,'a')] False
isSubmapOfBy :: Hashable k => (v1 -> v2 -> Bool) -> HashMap k v1 -> HashMap k v2 -> Boolunordered-containers Data.HashMap.Strict Inclusion of maps with value comparison. A map is included in another map if the keys are subsets and if the comparison function is true for the corresponding values:
isSubmapOfBy cmpV m1 m2 = keys m1 `isSubsetOf` keys m2 && and [ v1 `cmpV` v2 | (k1,v1) <- toList m1; let v2 = m2 ! k1 ]
Examples
>>> isSubmapOfBy (<=) (fromList [(1,'a')]) (fromList [(1,'b'),(2,'c')]) True
>>> isSubmapOfBy (<=) (fromList [(1,'b')]) (fromList [(1,'a'),(2,'c')]) False
fromMap :: HashMap a () -> HashSet aunordered-containers Data.HashSet Convert from the equivalent HashMap with () values.
>>> HashSet.fromMap (HashMap.singleton 1 ()) fromList [1]
toMap :: HashSet a -> HashMap a ()unordered-containers Data.HashSet Convert to set to the equivalent HashMap with () values.
>>> HashSet.toMap (HashSet.singleton 1) fromList [(1,())]
asMap :: HashSet a -> HashMap a ()unordered-containers Data.HashSet.Internal No documentation available.
fromMap :: HashMap a () -> HashSet aunordered-containers Data.HashSet.Internal Convert from the equivalent HashMap with () values.
>>> HashSet.fromMap (HashMap.singleton 1 ()) fromList [1]
toMap :: HashSet a -> HashMap a ()unordered-containers Data.HashSet.Internal Convert to set to the equivalent HashMap with () values.
>>> HashSet.toMap (HashSet.singleton 1) fromList [(1,())]
functionMap :: Function b => (a -> b) -> (b -> a) -> (a -> c) -> a :-> ctasty-quickcheck Test.Tasty.QuickCheck The basic building block for Function instances. Provides a Function instance by mapping to and from a type that already has a Function instance.
shrinkMap :: Arbitrary a => (a -> b) -> (b -> a) -> b -> [b]tasty-quickcheck Test.Tasty.QuickCheck Map a shrink function to another domain. This is handy if your data type has special invariants, but is almost isomorphic to some other type.
shrinkOrderedList :: (Ord a, Arbitrary a) => [a] -> [[a]] shrinkOrderedList = shrinkMap sort id shrinkSet :: (Ord a, Arbitrary a) => Set a -> [Set a] shrinkSet = shrinkMap fromList toList
shrinkMapBy :: (a -> b) -> (b -> a) -> (a -> [a]) -> b -> [b]tasty-quickcheck Test.Tasty.QuickCheck Non-overloaded version of shrinkMap.