parser -package:pfile
A pure interface to the module parser.
This parser can be used to parse
URI from strict
Text.
Remember to use a concrete non-polymorphic parser type for efficiency.
Parse an
IPv4 address using a
Parser.
>>> AT.parseOnly IPv4.parser "192.168.2.47"
Right (ipv4 192 168 2 47)
>>> AT.parseOnly IPv4.parser "192.168.2.470"
Left "Failed reading: All octets in an IPv4 address must be between 0 and 255"
Parse an
IPv6 using
Parser.
>>> Atto.parseOnly IPv6.parser (Text.pack "dead:beef:3240:a426:ba68:1cd0:4263:109b")
Right (ipv6 0xdead 0xbeef 0x3240 0xa426 0xba68 0x1cd0 0x4263 0x109b)
Parse a
Mac address using a
Parser.
>>> AT.parseOnly Mac.parser (Text.pack "a4:7f:24:7a:b4:23")
Right (mac 0xa47f247ab423)
>>> AT.parseOnly Mac.parser (Text.pack "a47-f24-7ab-423")
Left "':': Failed reading: satisfy"
Create a parser from the given grammar.
A greedy attoparsec
Parser which requires the entire
Text input to match.
A greedy attoparsec
Parser using the specified
Delimiters set which requires the entire
Text input to
match.
Parse a country from its name using an attoparsec text parser. This
function is language-agnostic and can handle any source language. In
the case that one possible country name is a prefix of another
possible name (for example, United States vs United States of
America), the longest possible will be parsed.
BEncode format parser according to specification.
Like
fmap, except the function may be partial (
Nothing
causes the wizard to fail).
A JSON parser. N.B. This might not fit your usual understanding of
"parser". Instead you might like to think of
Parser as a "parse
result", i.e. a parser to which the input has already been applied.
A separate
Parser data type ensures that we don't forget to
skip spaces.