<commit_before>module Char exposing
  ( isUpper, isLower, isDigit, isOctDigit, isHexDigit
  , toUpper, toLower, toLocaleUpper, toLocaleLower
  , KeyCode, toCode, fromCode
  )

{-| Functions for working with characters. Character literals are enclosed in
`'a'` pair of single quotes.

# Classification
@docs isUpper, isLower, isDigit, isOctDigit, isHexDigit

# Conversion
@docs toUpper, toLower, toLocaleUpper, toLocaleLower

# Key Codes
@docs KeyCode, toCode, fromCode

-}

import Native.Char
import Basics exposing ((&&), (||), (>=), (<=))


isBetween : Char -> Char -> Char -> Bool
isBetween low high char =
  let code = toCode char
  in
      (code >= toCode low) && (code <= toCode high)


{-| True for upper case ASCII letters. -}
isUpper : Char -> Bool
isUpper =
  isBetween 'A' 'Z'


{-| True for lower case ASCII letters. -}
isLower : Char -> Bool
isLower =
  isBetween 'a' 'z'


{-| True for ASCII digits `[0-9]`. -}
isDigit : Char -> Bool
isDigit =
  isBetween '0' '9'


{-| True for ASCII octal digits `[0-7]`. -}
isOctDigit : Char -> Bool
isOctDigit =
  isBetween '0' '7'


{-| True for ASCII hexadecimal digits `[0-9a-fA-F]`. -}
isHexDigit : Char -> Bool
isHexDigit char =
  isDigit char || isBetween 'a' 'f' char || isBetween 'A' 'F' char


{-| Convert to upper case. -}
toUpper : Char -> Char
toUpper =
  Native.Char.toUpper


{-| Convert to lower case. -}
toLower : Char -> Char
toLower =
  Native.Char.toLower


{-| Convert to upper case, according to any locale-specific case mappings. -}
toLocaleUpper : Char -> Char
toLocaleUpper =
  Native.Char.toLocaleUpper


{-| Convert to lower case, according to any locale-specific case mappings. -}
toLocaleLower : Char -> Char
toLocaleLower =
  Native.Char.toLocaleLower


{-| In this library, we use integers to represent the key codes coming from the
keyboard. You can use [`toCode`](#toCode) and [`fromCode`](#fromCode)
to convert between key codes and characters.
-}
type alias KeyCode = Int


{-| Convert to unicode. Used with the [`Keyboard`](Keyboard) library,
which expects the input to be uppercase.
-}
toCode : Char -> KeyCode
toCode =
  Native.Char.toCode


{-| Convert from unicode. -}
fromCode : KeyCode -> Char
fromCode =
  Native.Char.fromCode<commit_msg>Update docs of KeyCode to make more sense<commit_after>module Char exposing
  ( isUpper, isLower, isDigit, isOctDigit, isHexDigit
  , toUpper, toLower, toLocaleUpper, toLocaleLower
  , KeyCode, toCode, fromCode
  )

{-| Functions for working with characters. Character literals are enclosed in
`'a'` pair of single quotes.

# Classification
@docs isUpper, isLower, isDigit, isOctDigit, isHexDigit

# Conversion
@docs toUpper, toLower, toLocaleUpper, toLocaleLower

# Key Codes
@docs KeyCode, toCode, fromCode

-}

import Native.Char
import Basics exposing ((&&), (||), (>=), (<=))


isBetween : Char -> Char -> Char -> Bool
isBetween low high char =
  let code = toCode char
  in
      (code >= toCode low) && (code <= toCode high)


{-| True for upper case ASCII letters. -}
isUpper : Char -> Bool
isUpper =
  isBetween 'A' 'Z'


{-| True for lower case ASCII letters. -}
isLower : Char -> Bool
isLower =
  isBetween 'a' 'z'


{-| True for ASCII digits `[0-9]`. -}
isDigit : Char -> Bool
isDigit =
  isBetween '0' '9'


{-| True for ASCII octal digits `[0-7]`. -}
isOctDigit : Char -> Bool
isOctDigit =
  isBetween '0' '7'


{-| True for ASCII hexadecimal digits `[0-9a-fA-F]`. -}
isHexDigit : Char -> Bool
isHexDigit char =
  isDigit char || isBetween 'a' 'f' char || isBetween 'A' 'F' char


{-| Convert to upper case. -}
toUpper : Char -> Char
toUpper =
  Native.Char.toUpper


{-| Convert to lower case. -}
toLower : Char -> Char
toLower =
  Native.Char.toLower


{-| Convert to upper case, according to any locale-specific case mappings. -}
toLocaleUpper : Char -> Char
toLocaleUpper =
  Native.Char.toLocaleUpper


{-| Convert to lower case, according to any locale-specific case mappings. -}
toLocaleLower : Char -> Char
toLocaleLower =
  Native.Char.toLocaleLower


{-| Keyboard keys can be represented as integers. These are called *key codes*.
You can use [`toCode`](#toCode) and [`fromCode`](#fromCode) to convert between
key codes and characters.
-}
type alias KeyCode = Int


{-| Convert to key code.
-}
toCode : Char -> KeyCode
toCode =
  Native.Char.toCode


{-| Convert from key code. -}
fromCode : KeyCode -> Char
fromCode =
  Native.Char.fromCode
{'fraction_non_alphanumeric': 0.12826927450534456, 'fraction_numerical': 0.004548555833522857, 'mean_word_length': 3.576482830385016, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2427938', 'n_tokens_mistral': 1567, 'n_tokens_neox': 1463, 'n_words': 501}