scalpel
scalpel copied to clipboard
Suggestion : AttributePredicate combinators
When working with large chunks of HTML I found the need for binary combinators to combine predicates such as
(|||), (&&&) :: AttributePredicate -> AttributePredicate -> AttributePredicate
(|||) = liftAttributePredicate2 (||)
(&&&) = liftAttributePredicate2 (&&)
liftAttributePredicate2 :: (Bool -> Bool -> Bool)
-> AttributePredicate -> AttributePredicate -> AttributePredicate
liftAttributePredicate2 h (MkAttributePredicate f) (MkAttributePredicate g) =
MkAttributePredicate $ \x -> f x `h` g x
which are a bit "lighter" than using match.
Sounds reasonable, though I think I would suggest different operators since ||| and &&& already exist for arrows.
Maybe @&& and @|| which keeps with the pattern of existing attribute operators @=, @=~, and @:.