Safe Haskell | Safe |
---|---|
Language | Haskell98 |
ASCII utility functions.
- data IsAscii = IsAscii
- isAscii :: Property IsAscii v => v -> Bool
- type Ascii α = Checked IsAscii α
- maybeAscii :: Char -> Maybe Word8
- ascii :: Char -> Word8
- isControl :: Char -> Bool
- isPrintable :: Char -> Bool
- isWhiteSpace :: Char -> Bool
- isSpaceOrTab :: Char -> Bool
- isLower :: Char -> Bool
- isUpper :: Char -> Bool
- toLower :: Char -> Char
- toUpper :: Char -> Char
- isAlpha :: Char -> Bool
- isAlphaNum :: Char -> Bool
- isDecDigit :: Char -> Bool
- isNzDecDigit :: Char -> Bool
- fromDecDigit :: Num a => Char -> Maybe a
- fromNzDecDigit :: Num a => Char -> Maybe a
- unsafeFromDecDigit :: Num a => Char -> a
- isBinDigit :: Char -> Bool
- isNzBinDigit :: Char -> Bool
- fromBinDigit :: Num a => Char -> Maybe a
- fromNzBinDigit :: Num a => Char -> Maybe a
- unsafeFromBinDigit :: Num a => Char -> a
- isOctDigit :: Char -> Bool
- isNzOctDigit :: Char -> Bool
- fromOctDigit :: Num a => Char -> Maybe a
- fromNzOctDigit :: Num a => Char -> Maybe a
- unsafeFromOctDigit :: Num a => Char -> a
- isUpHexDigit :: Char -> Bool
- isNzUpHexDigit :: Char -> Bool
- fromUpHexDigit :: Num a => Char -> Maybe a
- fromNzUpHexDigit :: Num a => Char -> Maybe a
- unsafeFromUpHexDigit :: Num a => Char -> a
- isLowHexDigit :: Char -> Bool
- isNzLowHexDigit :: Char -> Bool
- fromLowHexDigit :: Num a => Char -> Maybe a
- fromNzLowHexDigit :: Num a => Char -> Maybe a
- unsafeFromLowHexDigit :: Num a => Char -> a
- isHexDigit :: Char -> Bool
- isNzHexDigit :: Char -> Bool
- fromHexDigit :: Num a => Char -> Maybe a
- fromNzHexDigit :: Num a => Char -> Maybe a
- unsafeFromHexDigit :: Num a => Char -> a
- isControl8 :: Word8 -> Bool
- isPrintable8 :: Word8 -> Bool
- isWhiteSpace8 :: Word8 -> Bool
- isSpaceOrTab8 :: Word8 -> Bool
- isLower8 :: Word8 -> Bool
- isUpper8 :: Word8 -> Bool
- toLower8 :: Word8 -> Word8
- toUpper8 :: Word8 -> Word8
- isAlpha8 :: Word8 -> Bool
- isAlphaNum8 :: Word8 -> Bool
- isDecDigit8 :: Word8 -> Bool
- isNzDecDigit8 :: Word8 -> Bool
- fromDecDigit8 :: Num a => Word8 -> Maybe a
- fromNzDecDigit8 :: Num a => Word8 -> Maybe a
- unsafeFromDecDigit8 :: Num a => Word8 -> a
- isBinDigit8 :: Word8 -> Bool
- isNzBinDigit8 :: Word8 -> Bool
- fromBinDigit8 :: Num a => Word8 -> Maybe a
- fromNzBinDigit8 :: Num a => Word8 -> Maybe a
- unsafeFromBinDigit8 :: Num a => Word8 -> a
- isOctDigit8 :: Word8 -> Bool
- isNzOctDigit8 :: Word8 -> Bool
- fromOctDigit8 :: Num a => Word8 -> Maybe a
- fromNzOctDigit8 :: Num a => Word8 -> Maybe a
- unsafeFromOctDigit8 :: Num a => Word8 -> a
- isUpHexDigit8 :: Word8 -> Bool
- isNzUpHexDigit8 :: Word8 -> Bool
- fromUpHexDigit8 :: Num a => Word8 -> Maybe a
- fromNzUpHexDigit8 :: Num a => Word8 -> Maybe a
- unsafeFromUpHexDigit8 :: Num a => Word8 -> a
- isLowHexDigit8 :: Word8 -> Bool
- isNzLowHexDigit8 :: Word8 -> Bool
- fromLowHexDigit8 :: Num a => Word8 -> Maybe a
- fromNzLowHexDigit8 :: Num a => Word8 -> Maybe a
- unsafeFromLowHexDigit8 :: Num a => Word8 -> a
- isHexDigit8 :: Word8 -> Bool
- isNzHexDigit8 :: Word8 -> Bool
- fromHexDigit8 :: Num a => Word8 -> Maybe a
- fromNzHexDigit8 :: Num a => Word8 -> Maybe a
- unsafeFromHexDigit8 :: Num a => Word8 -> a
ASCII checks
Property IsAscii Char Source # | |
Property IsAscii Word8 Source # | |
Property IsAscii ByteString Source # | |
Property IsAscii ByteString Source # | |
Property IsAscii Text Source # | |
Property IsAscii Text Source # | |
Property IsAscii α => Property IsAscii [α] Source # | |
Eq α => Eq (Ascii α) Source # | |
Ord α => Ord (Ascii α) Source # | |
Show α => Show (Ascii α) Source # | |
IsString α => IsString (Ascii α) Source # | |
Semigroup α => Semigroup (Ascii α) Source # | |
Monoid α => Monoid (Ascii α) Source # | |
FoldCase (Ascii Char) Source # | |
FoldCase (Ascii α) => FoldCase (Ascii [α]) Source # | |
FoldCase (Ascii ByteString) Source # | |
FoldCase (Ascii ByteString) Source # | |
FoldCase (Ascii Text) Source # | |
FoldCase (Ascii Text) Source # | |
Hashable α => Hashable (Ascii α) Source # | |
maybeAscii :: Char -> Maybe Word8 Source #
Map a character to its ASCII encoding if possible, otherwise
return Nothing
.
Character properties
isPrintable :: Char -> Bool Source #
Test if a character is an ASCII printable character.
isWhiteSpace :: Char -> Bool Source #
Test if a character is an ASCII whitespace character.
isSpaceOrTab :: Char -> Bool Source #
Test if a character is the SPACE or the TAB character.
toLower :: Char -> Char Source #
Map lower-case ASCII letters to the corresponding upper-case letters, leaving other characters as is.
toUpper :: Char -> Char Source #
Map upper-case ASCII letters to the corresponding lower-case letters, leaving other characters as is.
isAlphaNum :: Char -> Bool Source #
Test if a character is either an ASCII letter or a decimal digit.
isDecDigit :: Char -> Bool Source #
Test if a character is a decimal digit ('0' ... '9').
isNzDecDigit :: Char -> Bool Source #
Test if a character is a non-zero decimal digit ('1' ... '9').
fromDecDigit :: Num a => Char -> Maybe a Source #
Map a decimal digit to the corresponding number. Return Nothing
on
other inputs.
fromNzDecDigit :: Num a => Char -> Maybe a Source #
Map non-zero decimal digits to the corresponding numbers. Return
Nothing
on other inputs.
unsafeFromDecDigit :: Num a => Char -> a Source #
Map decimal digits to the corresponding numbers. No checks are performed.
isBinDigit :: Char -> Bool Source #
Test if a character is a binary digit ('0' or '1').
isNzBinDigit :: Char -> Bool Source #
Test if a character is the non-zero binary digit ('1').
fromBinDigit :: Num a => Char -> Maybe a Source #
Map binary digits to the corresponding numbers. Return Nothing
on
other inputs.
fromNzBinDigit :: Num a => Char -> Maybe a Source #
Map the digit '1' to the number 1. Return Nothing
on other inputs.
unsafeFromBinDigit :: Num a => Char -> a Source #
Map binary digits to the corresponding numbers. No checks are performed.
isOctDigit :: Char -> Bool Source #
Test if a character is an octal digit ('0' ... '7').
isNzOctDigit :: Char -> Bool Source #
Test if a character is a non-zero octal digit ('1' ... '7').
fromOctDigit :: Num a => Char -> Maybe a Source #
Map octal digits to the corresponding numbers. Return Nothing
on
other inputs.
fromNzOctDigit :: Num a => Char -> Maybe a Source #
Map non-zero octal digits to the corresponding numbers. Return
Nothing
on other inputs.
unsafeFromOctDigit :: Num a => Char -> a Source #
Map octal digits to the corresponding numbers. No checks are performed.
isUpHexDigit :: Char -> Bool Source #
Test if a character is an upper-case hexadecimal digit
('0' ... '9' or A
... F
).
isNzUpHexDigit :: Char -> Bool Source #
Test if a character is a non-zero upper-case hexadecimal digit
('1' ... '9' or A
... F
).
fromUpHexDigit :: Num a => Char -> Maybe a Source #
Map upper-case hexadecimal digits to the corresponding numbers.
Return Nothing
on other inputs.
fromNzUpHexDigit :: Num a => Char -> Maybe a Source #
Map non-zero upper-case hexadecimal digits to the corresponding numbers.
Return Nothing
on other inputs.
unsafeFromUpHexDigit :: Num a => Char -> a Source #
Map upper-case hexadecimal digits to the corresponding numbers. No checks are performed.
isLowHexDigit :: Char -> Bool Source #
Test if a character is a lower-case hexadecimal digit
('0' ... '9' or a
... f
).
isNzLowHexDigit :: Char -> Bool Source #
Test if a character is a non-zero lower-case hexadecimal digit
('1' ... '9' or a
... f
).
fromLowHexDigit :: Num a => Char -> Maybe a Source #
Map lower-case hexadecimal digits to the corresponding numbers.
Return Nothing
on other inputs.
fromNzLowHexDigit :: Num a => Char -> Maybe a Source #
Map non-zero lower-case hexadecimal digits to the corresponding numbers.
Return Nothing
on other inputs.
unsafeFromLowHexDigit :: Num a => Char -> a Source #
Map lower-case hexadecimal digits to the corresponding numbers. No checks are performed.
isHexDigit :: Char -> Bool Source #
Test if a character is a hexadecimal digit
('0' ... '9' or a
... f
or A
... F
).
isNzHexDigit :: Char -> Bool Source #
Test if a character is a non-zero hexadecimal digit
('1' ... '9' or a
... f
or A
... F
).
fromHexDigit :: Num a => Char -> Maybe a Source #
Map hexadecimal digits to the corresponding numbers.
Return Nothing
on other inputs.
fromNzHexDigit :: Num a => Char -> Maybe a Source #
Map non-zero hexadecimal digits to the corresponding numbers.
Return Nothing
on other inputs.
unsafeFromHexDigit :: Num a => Char -> a Source #
Map hexadecimal digits to the corresponding numbers. No checks are performed.
Byte properties
isControl8 :: Word8 -> Bool Source #
Test if a byte is the encoding of an ASCII control character.
isPrintable8 :: Word8 -> Bool Source #
Test if a byte is the encoding of an ASCII printable character.
isWhiteSpace8 :: Word8 -> Bool Source #
Test if a byte is the encoding of an ASCII whitespace character.
isSpaceOrTab8 :: Word8 -> Bool Source #
Test if a byte is the encoding of the SPACE or the TAB character.
toLower8 :: Word8 -> Word8 Source #
Map the encodings of lower-case ASCII letters to the encodings of the corresponding upper-case letters, leaving other bytes as is.
toUpper8 :: Word8 -> Word8 Source #
Map the encodings of upper-case ASCII letters to the encodings of the corresponding lower-case letters, leaving other bytes as is.
isAlphaNum8 :: Word8 -> Bool Source #
Test if a byte is the encoding of either an ASCII letter or a decimal digit.
isDecDigit8 :: Word8 -> Bool Source #
Test if a byte is the encoding of a decimal digit ('0' ... '9').
isNzDecDigit8 :: Word8 -> Bool Source #
Test if a byte is the encoding of a non-zero decimal digit ('1' ... '9').
fromDecDigit8 :: Num a => Word8 -> Maybe a Source #
Map the encoding of a decimal digit to the corresponding number.
Return Nothing
on other inputs.
fromNzDecDigit8 :: Num a => Word8 -> Maybe a Source #
Map the encoding of a non-zero decimal digit to the corresponding number.
Return Nothing
on other inputs.
unsafeFromDecDigit8 :: Num a => Word8 -> a Source #
Map the encoding of a decimal digit to the corresponding number. No checks are performed.
isBinDigit8 :: Word8 -> Bool Source #
Test if a byte is the encoding of a binary digit ('0' or '1').
isNzBinDigit8 :: Word8 -> Bool Source #
Test if a byte is the encoding of the non-zero binary digit ('1').
fromBinDigit8 :: Num a => Word8 -> Maybe a Source #
Map the encoding of a binary digit to the corresponding number.
Return Nothing
on other inputs.
fromNzBinDigit8 :: Num a => Word8 -> Maybe a Source #
Map the encoding of the digit '1' to the number 1.
Return Nothing
on other inputs.
unsafeFromBinDigit8 :: Num a => Word8 -> a Source #
Map the encoding of a binary digit to the corresponding number. No checks are performed.
isOctDigit8 :: Word8 -> Bool Source #
Test if a byte is the encoding of an octal digit ('0' ... '7').
isNzOctDigit8 :: Word8 -> Bool Source #
Test if a byte is the encoding of a non-zero octal digit ('1' ... '7').
fromOctDigit8 :: Num a => Word8 -> Maybe a Source #
Map the encoding of an octal digit to the corresponding number.
Return Nothing
on other inputs.
fromNzOctDigit8 :: Num a => Word8 -> Maybe a Source #
Map the encoding of a non-zero octal digit to the corresponding number.
Return Nothing
on other inputs.
unsafeFromOctDigit8 :: Num a => Word8 -> a Source #
Map the encoding of an octal digit to the corresponding number. No checks are performed.
isUpHexDigit8 :: Word8 -> Bool Source #
Test if a byte is the encoding of an upper-case hexadecimal digit
('0' ... '9' or A
... F
).
isNzUpHexDigit8 :: Word8 -> Bool Source #
Test if a byte is the encoding of a non-zero upper-case hexadecimal digit
('1' ... '9' or A
... F
).
fromUpHexDigit8 :: Num a => Word8 -> Maybe a Source #
Map the encoding of an upper-case hexadecimal digit to the corresponding
number. Return Nothing
on other inputs.
fromNzUpHexDigit8 :: Num a => Word8 -> Maybe a Source #
Map the encoding of a non-zero upper-case hexadecimal digit to
the corresponding number. Return Nothing
on other inputs.
unsafeFromUpHexDigit8 :: Num a => Word8 -> a Source #
Map the encoding of an upper-case hexadecimal digit to the corresponding number. No checks are performed.
isLowHexDigit8 :: Word8 -> Bool Source #
Test if a byte is the encoding of a lower-case hexadecimal digit
('0' ... '9' or a
... f
).
isNzLowHexDigit8 :: Word8 -> Bool Source #
Test if a byte is the encoding of a non-zero lower-case hexadecimal digit
('1' ... '9' or a
... f
).
fromLowHexDigit8 :: Num a => Word8 -> Maybe a Source #
Map the encoding of a lower-case hexadecimal digit to the corresponding
number. Return Nothing
on other inputs.
fromNzLowHexDigit8 :: Num a => Word8 -> Maybe a Source #
Map the encoding of a non-zero lower-case hexadecimal digit to
the corresponding number. Return Nothing
on other inputs.
unsafeFromLowHexDigit8 :: Num a => Word8 -> a Source #
Map the encoding of a lower-case hexadecimal digit to the corresponding number. No checks are performed.
isHexDigit8 :: Word8 -> Bool Source #
Test if a byte is the encoding of a hexadecimal digit
('0' ... '9' or a
... f
or A
... F
).
isNzHexDigit8 :: Word8 -> Bool Source #
Test if a byte is the encoding of a non-zero hexadecimal digit
('1' ... '9' or a
... f
or A
... F
).
fromHexDigit8 :: Num a => Word8 -> Maybe a Source #
Map the encoding of a hexadecimal digit to the corresponding
number. Return Nothing
on other inputs.
fromNzHexDigit8 :: Num a => Word8 -> Maybe a Source #
Map the encoding of a non-zero hexadecimal digit to the corresponding
number. Return Nothing
on other inputs.
unsafeFromHexDigit8 :: Num a => Word8 -> a Source #
Map the encoding of a hexadecimal digit to the corresponding number. No checks are performed.