Copyright | Bryan O'Sullivan 2007-2015, Winterland 2016 |
---|---|
License | BSD3 |
Maintainer | drkoster@qq.com |
Stability | experimental |
Portability | unknown |
Safe Haskell | None |
Language | Haskell2010 |
This module is intended for parsing text that is represented using an 8-bit character set, e.g. ASCII or ISO-8859-15. It does not make any attempt to deal with character encodings, multibyte characters, or wide characters. In particular, all attempts to use characters above code point U+00FF will give wrong answers.
Code points below U+0100 are simply translated to and from their
numeric values, so e.g. the code point U+00A4 becomes the byte
0xA4
(which is the Euro symbol in ISO-8859-15, but the generic
currency sign in ISO-8859-1). Haskell Char
values above U+00FF
are truncated, so e.g. U+1D6B7 is truncated to the byte 0xB7
.
- peekMaybe :: Get (Maybe Char)
- peek :: Get Char
- satisfy :: (Char -> Bool) -> Get Char
- satisfyWith :: (Char -> a) -> (a -> Bool) -> Get a
- char :: Char -> Get ()
- anyChar :: Get Char
- skipChar :: (Char -> Bool) -> Get ()
- takeTill :: (Char -> Bool) -> Get ByteString
- takeWhile :: (Char -> Bool) -> Get ByteString
- takeWhile1 :: (Char -> Bool) -> Get ByteString
- skipWhile :: (Char -> Bool) -> Get ()
- stringCI :: ByteString -> Get ByteString
- isSpace :: Char -> Bool
- isDigit :: Char -> Bool
- isHexDigit :: Char -> Bool
- isHorizontalSpace :: Char -> Bool
- isEndOfLine :: Char -> Bool
Documentation
peekMaybe :: Get (Maybe Char) Source
Match any char, to perform lookahead. Returns Nothing
if end of
input has been reached. Does not consume any input.
Match any char, to perform lookahead. Does not consume any input, but will fail if end of input has been reached.
satisfy :: (Char -> Bool) -> Get Char Source
The parser satisfy p
succeeds for any char for which the
predicate p
returns True
. Returns the char that is actually
parsed.
satisfyWith :: (Char -> a) -> (a -> Bool) -> Get a Source
The parser satisfyWith f p
transforms a char, and succeeds if
the predicate p
returns True
on the transformed value. The
parser returns the transformed char that was parsed.
skipChar :: (Char -> Bool) -> Get () Source
The parser skipChar p
succeeds for any char for which the predicate p
returns True
.
takeTill :: (Char -> Bool) -> Get ByteString Source
Consume input as long as the predicate returns False
or reach the end of input,
and return the consumed input.
takeWhile :: (Char -> Bool) -> Get ByteString Source
Consume input as long as the predicate returns True
or reach the end of input,
and return the consumed input.
takeWhile1 :: (Char -> Bool) -> Get ByteString Source
skipWhile :: (Char -> Bool) -> Get () Source
Skip past input for as long as the predicate returns True
.
stringCI :: ByteString -> Get ByteString Source
Satisfy a literal string but ignoring case.
isSpace :: Char -> Bool Source
Fast predicate for matching ASCII space characters.
Note: This predicate only gives correct answers for the ASCII
encoding. For instance, it does not recognise U+00A0 (non-breaking
space) as a space character, even though it is a valid ISO-8859-15
byte. For a Unicode-aware and only slightly slower predicate,
use isSpace
isHexDigit :: Char -> Bool Source
Hex digit predicate.
isHorizontalSpace :: Char -> Bool Source
A predicate that matches either a space ' '
or horizontal tab
'\t'
character.
isEndOfLine :: Char -> Bool Source
A predicate that matches either a carriage return '\r'
or
newline '\n'
character.