Copyright | (c) Eric Mertens 2018-2021 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
When day is specified as 0
the quasiquoter returns a pure
parser function. Otherwise day uses command line arguments
to find the input file and parses it as an IO action.
A format string can optionally be specified across multiple
lines. In this case the day number goes on the first line and
the pattern starts on the second line. All common leading white
space from all the remaining lines is trimmed off and newlines
are discarded (use %n
for matching newlines)
The following are identical:
example1 = [format|2021 1 %s%n %s%n|] example2 = [format|2021 1 %s%n%s%n|]
Patterns:
%u
unsigned integer asInt
%d
signed integer asInt
%lu
unsigned integer asInteger
%ld
signed integer asInteger
%s
non-empty list of non-space characters asString
%c
single, non-newline character asChar
%a
single ASCII letter asChar
%n
single newline character- other characters match literally
- use
%
to escape literal matches of special characters @A
matches the names of the constructors of typeA
as anA
Structures:
p|q
combine alternativesp
andq
(pq)
group subpatternpq
p*
zero-to-many repititions ofp
as a '[]'p+
one-to-many repititions ofp
as a '[]'p&q
zero-to-many repititions ofp
separated byq
as a '[]'p!
returns the characters that matched patternp
as aString
Synopsis
Documentation
format :: QuasiQuoter Source #
Constructs an input parser. See Advent.Format