Unicode.Char.Numeric

unicode-data-0.4.0.1: Access Unicode Character Database (UCD)

Copyright | (c) 2020 Composewell Technologies and Contributors
License | Apache-2.0
Maintainer | streamly@composewell.com
Stability | experimental
Safe Haskell | Safe-Inferred
Language | Haskell2010

Unicode.Char.Numeric

Contents

- Predicates
- Numeric values
- Re-export from `base`

Description

Numeric character property related functions.

Since: 0.3.0

Synopsis

- isNumeric :: Char -> Bool
- isNumber :: Char -> Bool
- numericValue :: Char -> Maybe Rational
- integerValue :: Char -> Maybe Int
- isDigit :: Char -> Bool
- isOctDigit :: Char -> Bool
- isHexDigit :: Char -> Bool
- digitToInt :: Char -> Int
- intToDigit :: Int -> Char

# Predicates

isNumeric :: Char -> Bool #

Selects Unicode character with a numeric value.

Note: a character may have a numeric value but return `False` with the predicate `isNumber`, because `isNumber` only tests `GeneralCategory`: some CJK characters are `OtherLetter` and do have a numeric value.

    isNumeric c == isJust (numericValue c)

Since: 0.3.1

isNumber :: Char -> Bool #

Deprecated: Use Unicode.Char.Numeric.Compat.isNumber instead. This function will be a synonym for isNumeric in a future release. See Unicode.Char.Numeric.Compat for behavior compatible with base:Data.Char.

Selects Unicode numeric characters, including digits from various scripts, Roman numerals, et cetera.

This function returns `True` if its argument has one of the following `GeneralCategory`s, or `False` otherwise:

- `DecimalNumber`
- `LetterNumber`
- `OtherNumber`

Note: a character may have a numeric value (see `numericValue`) but return `False`, because `isNumber` only tests `GeneralCategory`: some CJK characters are `OtherLetter` and do have a numeric value. Use `isNumeric` to cover those cases as well.

    isNumber c == Data.Char.isNumber c

Since: 0.3.0

# Numeric values

numericValue :: Char -> Maybe Rational #

Numeric value of a character, if relevant.

Note: a character may have a numeric value but return `False` with the predicate `isNumber`, because `isNumber` only tests `GeneralCategory`: some CJK characters are `OtherLetter` and do have a numeric value.

Since: 0.3.1

integerValue :: Char -> Maybe Int #

Integer value of a character, if relevant.

This is a special case of `numericValue`.

Note: a character may have a numeric value but return `False` with the predicate `isNumber`, because `isNumber` only tests `GeneralCategory`: some CJK characters are `OtherLetter` and do have a numeric value.

Since: 0.3.1

# Re-export from `base`

isDigit :: Char -> Bool #

isOctDigit :: Char -> Bool #

isHexDigit :: Char -> Bool #

digitToInt :: Char -> Int #

intToDigit :: Int -> Char #