@@ -13,6 +13,26 @@ instance Alternative (PARSER) where
1313 empty = zero
1414 (<|>) = plus
1515
16+-- | Match any character in a set.
17+--
18+-- > vowel = inClass "aeiou"
19+--
20+-- Range notation is supported.
21+--
22+-- > halfAlphabet = inClass "a-nA-N"
23+--
24+-- To add a literal \'-\' to a set, place it at the beginning or end
25+-- of the string.
26+inClass :: String -> Word8 -> Bool
27+inClass s = (`memberWord8` mySet)
28+ where mySet = charClass s
29+{-# INLINE inClass #-}
30+
31+-- | Match any character not in a set.
32+notInClass :: String -> Word8 -> Bool
33+notInClass s = not . inClass s
34+{-# INLINE notInClass #-}
35+
1636-- | Skip over bytes while the predicate is true.
1737skipWhile :: (Word8 -> Bool) -> PARSER ()
1838skipWhile p = takeWhile p *> pure ()