module Regex.Internal.CharSets
  ( digit
  , word
  , space
  , ascii
  , asciiAlpha
  , asciiUpper
  , asciiLower
  ) where

import Regex.Internal.CharSet (CharSet)
import qualified Regex.Internal.CharSet as CS

-- | ASCII digits. @\'0\'..\'9\'@. Agrees with 'Data.Char.isDigit'.
digit :: CharSet
digit :: CharSet
digit = (Char, Char) -> CharSet
CS.fromRange (Char
'0',Char
'9')

-- | ASCII alphabet, digits and underscore.
-- @\'A\'..\'Z\',\'a\'..\'z\',\'0\'..\'9\',\'_\'@.
word :: CharSet
word :: CharSet
word = CharSet
asciiUpper CharSet -> CharSet -> CharSet
forall a. Semigroup a => a -> a -> a
<> CharSet
asciiLower CharSet -> CharSet -> CharSet
forall a. Semigroup a => a -> a -> a
<> CharSet
digit CharSet -> CharSet -> CharSet
forall a. Semigroup a => a -> a -> a
<> Char -> CharSet
CS.singleton Char
'_'

-- | Unicode space characters and the control characters
-- @\'\\t\',\'\\n\',\'\\r\',\'\\f\',\'\\v\'@.
-- Agrees with 'Data.Char.isSpace'.
space :: CharSet
space :: CharSet
space = [Char] -> CharSet
CS.fromList [Char]
"\t\n\r\f\v"
     CharSet -> CharSet -> CharSet
forall a. Semigroup a => a -> a -> a
<> [Char] -> CharSet
CS.fromList [Char]
"\x0020\x00A0\x1680\x202F\x205F\x3000"
     CharSet -> CharSet -> CharSet
forall a. Semigroup a => a -> a -> a
<> (Char, Char) -> CharSet
CS.fromRange (Char
'\x2000',Char
'\x200A')

-- | ASCII @Char@s. @\'\\0\'..\'\\127\'@. Agrees with 'Data.Char.isAscii'.
ascii :: CharSet
ascii :: CharSet
ascii = (Char, Char) -> CharSet
CS.fromRange (Char
'\0',Char
'\127')

-- | ASCII alphabet. @\'A\'..\'Z\',\'a\'..\'z\'@.
asciiAlpha :: CharSet
asciiAlpha :: CharSet
asciiAlpha = CharSet
asciiUpper CharSet -> CharSet -> CharSet
forall a. Semigroup a => a -> a -> a
<> CharSet
asciiLower

-- | ASCII uppercase @Char@s. @\'A\'..\'Z\'@. Agrees with
-- 'Data.Char.isAsciiUpper'.
asciiUpper :: CharSet
asciiUpper :: CharSet
asciiUpper = (Char, Char) -> CharSet
CS.fromRange (Char
'A',Char
'Z')

-- | ASCII lowercase @Char@s. @\'a\'..\'z\'@. Agrees with
-- 'Data.Char.isAsciiLower'.
asciiLower :: CharSet
asciiLower :: CharSet
asciiLower = (Char, Char) -> CharSet
CS.fromRange (Char
'a',Char
'z')