@@ -25,6 +25,8 @@ module Text.XML.Lens (
2525 -- ** Attributes
2626 , attributeIs
2727 , attributeSatisfies
28+ , attributeSatisfies'
29+ , withoutAttribute
2830 , attr
2931 , attribute
3032 , attrs
@@ -62,6 +64,7 @@ import Data.Text (Text)
6264import Data.Map (Map)
6365import Control.Applicative
6466import qualified Data.CaseInsensitive as CI
67+import Data.Maybe (isNothing)
6568
6669infixr 9 ./
6770
@@ -171,7 +174,13 @@ el n f s
171174 | otherwise = pure s
172175
173176attributeSatisfies :: Name -> (Text -> Bool) -> Traversal' Element Element
174−attributeSatisfies n p = filtered (maybe False p . preview (attrs . ix n))
177+attributeSatisfies n p = attributeSatisfies' n (maybe False p)
178+
179+attributeSatisfies' :: Name -> (Maybe Text -> Bool) -> Traversal' Element Element
180+attributeSatisfies' n p = filtered (p . preview (attrs . ix n))
181+
182+withoutAttribute :: Name -> Traversal' Element Element
183+withoutAttribute n = attributeSatisfies' n isNothing
175184
176185attributeIs :: Name -> Text -> Traversal' Element Element
177186attributeIs n v = attributeSatisfies n (==v)