Commit Graph

438 Commits

Author SHA1 Message Date
Simon Jakobi
13c62e41fc Support mtl-2.3 2022-05-09 09:58:16 +02:00
Mark Karpov
d5556790fa Test with 3 latest versions of GHC, update Ormolu 2021-12-04 13:53:48 +01:00
Anton-Latukha
9a71a45399 Mention the performance advantages of takeWhile1P in its docs 2021-11-16 23:42:38 +01:00
Ben Orchard
064edbddd6 Add binary-format number parsers 2021-08-15 19:59:16 +02:00
Mark Karpov
925813d066 Add Safe annotation to the Text.Megaparsec.Error boot file 2021-08-14 19:06:57 +02:00
Anton-Latukha
9d92f5a490 Improve the docs for Text.Megaparsec.Class.token 2021-08-11 18:35:09 +02:00
Mark Karpov
5d4e3e7cfd Add a debugging helper that doesn't require a Show instance 2021-07-14 21:29:05 +02:00
Mark Karpov
e6fbc3d822 Fix CI (Trustworthy / Safe) 2021-07-14 21:01:09 +02:00
Mark Karpov
ed6fdf71d9 Improve the writing 2021-04-25 16:03:52 +02:00
Mark Karpov
c5d6bb362c Test with GHC 9.0.1 and 8.10.4 2021-03-01 01:18:16 +01:00
Dennis Gosnell
7dda58a2f7
Fix Haddock link to Text.Megaparsec.Char.space1 2021-01-08 13:30:45 +01:00
Artem Pelenitsyn
55063c15ed typo in docs 2020-12-20 13:36:29 +01:00
Mark Karpov
040a1be79e
Add a performance note to the dos of ‘satisfy’
Close #434.
2020-12-14 12:08:57 +01:00
Mark Karpov
7391c09bfb
Mention that the ‘MonadPlus’ instance is unlawful
Close #430, close #429.
2020-10-30 12:06:20 +01:00
mlugg
ccf314b0b9 Add Safe Haskell support
Remove dependence on GeneralizedNewtypeDeriving and add Safe Haskell
extensions to every file.
2020-10-17 18:53:15 +02:00
Mark Karpov
1f574c42ea
Fix a typo in the docs for ‘hspace1’
Close #424
2020-09-26 16:55:51 +02:00
1computer1
34b34c3d93 Decouple the error reporting-related methods from ‘Stream’
Split the ‘Stream’ type class. The methods ‘showTokens’ and ‘tokensLength’
have been put into a separate type class ‘VisualStream’, while ‘reachOffset’
and ‘reachOffsetNoLine’ are now in ‘TraversableStream’. This should make
defining ‘Stream’ instances for custom streams easier.

Defined ‘Stream’ instances for lists and ‘Seq’s.
2020-09-02 19:50:45 +02:00
Mark Karpov
e42f42a943
Re-format with Ormolu 0.1.2.0 2020-07-17 12:13:07 +02:00
Mark Karpov
46f276a0cc Add ‘hspace’ and ‘hspace1’ functions
These functions are slightly more specific versions of the existing ‘space’
functions. They accept only “horizontal whitespace”.
2020-05-10 22:53:16 +02:00
Mark Karpov
99e640ec39
Format the source code with Ormolu 2020-04-23 22:05:36 +02:00
Jonathan Curran
4c8ea278e3 Update comment to reflect updated function name
`anyChar` was renamed to `anySingle` in 7.0.0 - this simply updates the outdated comment
2019-11-28 19:32:11 +01:00
mrkkrp
20811826ca
Update the links to the tutorial 2019-11-22 23:16:51 +01:00
mrkkrp
31b917b129 Allow registration of delayed parse errors
Megaparsec now supports registration of “delayed” parse errors. On lower
level we added a new field called ‘stateParseErrors’ to the ‘State’ record.
The type also had to change from ‘State s’ to ‘State s e’. This field
contains the list of registered ‘ParseErrors’ that do not end parsing
immediately but still will cause failure in the end if the list is not
empty. Users are expected to register parse errors using the three
functions: ‘registerParseError’, ‘registerFailure’, and
‘registerFancyFailure’. These functions are analogous to those without the
‘register’ prefix, except that they have “delayed” effect.
2019-11-07 12:48:56 +01:00
mrkkrp
f8ef95c025 Re-organize error reporting functions
The methods ‘failure’ and ‘fancyFailure’ of ‘MonadParsec’ are now ordinary
functions and live in ‘Text.Megaparsec’. They are defined in terms of the
new ‘parseError’ method of ‘MonadParsec’. This method allows us to signal
parse errors at a given offset without manipulating parser state manually.
2019-11-05 14:18:55 +01:00
Tobias Markus
9c9f7d4e08 Allow Stream to specify custom token width
Currently, the errorItemLength function implicitly assumes that every token
spans exactly one character. That assumption is correct for the Stream
instances for the basic string types (String/Text/ByteString) included in
Megaparsec. It does not necessarily hold for custom token types however,
in particular if using a separate lexer pass.

This commit adds a new tokensLength function that allows the Stream instance
to give a custom width for a non-empty token stream.

In practice, parse errors concerning a token with a width greater than 1
are currently rendered incorrectly (only one caret is displayed below
the offending token).
2019-10-27 14:58:46 +01:00
mrkkrp
b3997ee18d
Test with GHC 8.8.1 on CI 2019-09-25 22:05:04 +02:00
mrkkrp
ffe596c6ce Drop some CPP, drop support for GHC 8.2.x
Since there are currently blockers preventing compilation of ‘cirterion’
with GHC 8.8.1, I've decided not to add this version of GHC to the build
matrix and add it later instead.
2019-09-15 23:00:55 +02:00
mrkkrp
87d425759a Simplify type signatures of ‘reachOffset’ and ‘reachOffsetNoLine’
Changed type signatures of ‘reachOffset’ and ‘reachOffsetNoLine’ methods of
the ‘Stream’ type class. Instead of three-tuple ‘reachOffset’ now returns
two-tuple because ‘SourcePos’ is already contained in the returned
‘PosState’ record.
2019-07-13 17:37:46 +02:00
mrkkrp
de4fddad7a
Use the word “present” instead of current year in copyright notes
[skip ci]
2019-07-02 21:41:24 +02:00
mrkkrp
d391a98177 Generalize numeric parsers in lexer modules
It appears that we can relax constraints for ‘decimal’, ‘binary’, ‘octal’,
and ‘hexadecimal’ from ‘Integral’ to ‘Num’ keeping the same implementations.
2019-07-02 19:58:34 +02:00
mrkkrp
b8cbbfce57 Drop support for GHC 7.10 2019-04-30 10:57:56 +02:00
klebinger.andreas@gmx.at
b0a2df80d1 Adapt to MonadFail changes in base 4.13.
Base 4.13 will remove the fail method from the Monad class
so we no longer have to/can define it.

So we remove the the definitions from the Monad instances
using CPP for versions of base >= 4.13
2019-04-13 17:05:25 +02:00
mrkkrp
a4e68d9b1f
Drop an oldish comment 2019-01-30 17:14:34 +01:00
mrkkrp
b83f1b1e34
Update copyright years
[skip ci]
2019-01-01 12:50:48 +07:00
mrkkrp
b200b09830
Numerous documentation corrections 2018-11-07 12:21:00 +07:00
Fraser Tweedale
cbed2f2cb6 Fix build with mtl < v2.2.2 (#331)
Commit 56c89cba24 removed a CPP
conditional.  mtl Control.Monad.Identity only exports
Control.Monad.Trans.Identity as of v2.2.2.  Therefore IdentityT is
not in scope with mtl < v2.2.2. and the build fails.

Restore the CPP block to fix building with mtl < v2.2.2.
2018-10-31 14:41:57 +07:00
mrkkrp
e556853725
Drop ‘liftM’ 2018-10-26 20:07:46 +07:00
mrkkrp
65524a6a4f
Fix another typo
[skip ci]
2018-09-27 21:12:00 +07:00
mrkkrp
56c89cba24
Drop some redundant CPP 2018-09-26 20:48:13 +07:00
Luc Tielen
e8bfc87832 More descriptive error when elabel or ulabel is used incorrectly (#327) 2018-09-23 21:27:55 +07:00
mrkkrp
07523e84a8
Minor documentation updates
[skip ci]
2018-09-22 22:41:07 +07:00
Mark Karpov
a6985ad98b
Fix a bug in ‘errorBundlePretty’ (#322)
Previously the question sign ‘?’ was erroneously inserted before offending
line in 2nd and later parse errors.
2018-09-15 16:06:02 +07:00
mrkkrp
b0335b6946
Misc improvements in the docs 2018-09-05 02:24:28 +07:00
Mark Karpov
d43ab7c943
Adjust continuous highlighting so it doesn't get too long (#321) 2018-09-04 22:05:53 +07:00
Mark Karpov
9698fe325c
Implement the ‘attachSourcePos’ function (#320) 2018-09-03 22:16:27 +07:00
Mark Karpov
4e79ac91b2
Do not alter labels artificially (#319)
In particular, don't prepend the phrase “the rest of ”.
2018-09-02 23:29:38 +07:00
Mark Karpov
e3072661ad
Optimize ‘reachOffset’, introduce ‘reachOffsetNoLine’ (#318)
Fetching line makes for a major slow-down, we cannot afford this.
2018-08-31 22:20:35 +07:00
Galen Huntington
cdb9334d61 Language extension needed for GHC 8.6. (#317) 2018-08-28 10:40:01 +07:00
Mark Karpov
573bacf721
Use offset in parse errors (#313)
The change allows to speed-up parsers in most cases and re-use the fact that
we're traversing input stream on pretty-printing ‘ParseError’s anyway.
2018-08-20 23:35:10 +07:00
Mark Karpov
65adeb7574
Improve case-insensitive char matching (#310)
Improved case-insensitive character matching in the cases when e.g.
‘isLower’ and ‘isUpper’ both return ‘False’. Functions affected:
‘Text.Megaparsec.Char.char'’.

Also re-implemented ‘Text.Megaparsec.Byte.char'’ without semantic changes.
2018-07-22 14:29:09 +07:00