module Hasql.TH.Syntax.Predicate where
import Hasql.TH.Prelude hiding (expression)
import qualified Data.HashSet as HashSet
import qualified Hasql.TH.Syntax.HashSet as HashSet
oneOf :: [a -> Bool] -> a -> Bool
oneOf = foldr (\ a b c -> a c || b c) (const False)
inSet :: (Eq a, Hashable a) => HashSet a -> a -> Bool
inSet = flip HashSet.member
firstIdentifierChar :: Char -> Bool
firstIdentifierChar x = isAlpha x || x == '_' || x >= '\200' && x <= '\377'
notFirstIdentifierChar :: Char -> Bool
notFirstIdentifierChar x = isAlphaNum x || x == '_' || x == '$' || x >= '\200' && x <= '\377'
keyword :: Text -> Bool
keyword = inSet HashSet.keyword
unreservedKeyword :: Text -> Bool
unreservedKeyword = inSet HashSet.unreservedKeyword
colNameKeyword :: Text -> Bool
colNameKeyword = inSet HashSet.colNameKeyword
typeFuncNameKeyword :: Text -> Bool
typeFuncNameKeyword = inSet HashSet.typeFuncNameKeyword
reservedKeyword :: Text -> Bool
reservedKeyword = inSet HashSet.reservedKeyword
symbolicBinOpChar :: Char -> Bool
symbolicBinOpChar = inSet HashSet.symbolicBinOpChars
opChar = inSet HashSet.opChars
prohibitedOpChar a = a == '+' || a == '-'
prohibitionLiftingOpChar = inSet HashSet.prohibitionLiftingOpChars