Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Documentation
module Data.Map
exactKeys :: Ord k => Map k a -> Set k -> Either (Set k) (Map k a) Source #
If s
is a subset of the keys in m
then
m exactKeys s = Right (m `restrictKeys` s)
Otherwise, m exactKeys s = Left s'
where s'
is the keys that are missing
from m
.
Examples
>>>
:{
>>>
fromList [('a', 1), ('b', 2), ('c', 3)]
>>>
`exactKeys` Set.fromList ['a', 'b']
>>>
:}
Right (fromList [('a',1),('b',2)])
>>>
:{
>>>
fromList [('a', 1), ('b', 2), ('c', 3)]
>>>
`exactKeys` Set.fromList ['a', 'x', 'y']
>>>
:}
Left (fromList "xy")