Parsing.String.Basic
- Package
- purescript-parsing
- Repository
- purescript-contrib/purescript-parsing
Basic String
parsers derived from primitive String
parsers.
unicode dependency
Some of the parsers in this module depend on the unicode package. The unicode package is large; about half a megabyte unminified. If code which depends on parsing is “tree-shaken” “dead-code-eliminated,” then all of the unicode package will be eliminated.
The unicode-dependent parsers in this module will call functions which use large lookup tables from the unicode package. Using any of these unicode-dependent parsers may result in a minified, dead-code-eliminated bundle size increase of over 100 kilobytes.
#intDecimal Source
intDecimal :: forall m. ParserT String m Int
Parser based on the Data.Int.fromString function.
This should be the inverse of show :: Int -> String
.
Examples of strings which can be parsed by this parser:
"3"
"-3"
"+300"
#takeWhile Source
takeWhile :: forall m. (CodePoint -> Boolean) -> ParserT String m String
Take the longest String
for which the characters satisfy the
predicate.
See Data.CodePoint.Unicode
for useful predicates.
Example:
runParser "Tackling the Awkward Squad" do
takeWhile Data.CodePoint.Unicode.isLetter
Right "Tackling"
You should prefer takeWhile isLetter
to
fromCharArray <$> Data.Array.many letter
.
#takeWhile1 Source
takeWhile1 :: forall m. (CodePoint -> Boolean) -> ParserT String m String
Take the longest String
for which the characters satisfy the
predicate. Require at least 1 character. You should supply an
expectation description for the error
message for when the predicate fails on the first character.
See Data.CodePoint.Unicode
for useful predicates.
Example:
runParser "Tackling the Awkward Squad" do
takeWhile1 Data.CodePoint.Unicode.isLetter <?> "a letter"
Right "Tackling"
#whiteSpace Source
whiteSpace :: forall m. ParserT String m String
Match zero or more whitespace characters satisfying
Data.CodePoint.Unicode.isSpace
.
Always succeeds. Will consume only when matched whitespace string is non-empty.
#skipSpaces Source
skipSpaces :: forall m. ParserT String m Unit
Skip whitespace characters satisfying Data.CodePoint.Unicode.isSpace
and throw them away.
Always succeeds. Will only consume when some characters are skipped.