Comments (5)
I think I will start writing tests for Text.Megaparsec.Perm
— permutation parsers. The module is quite minimal and at the same time not everyone is familiar with the concept of permutation parsers, so I think it's easier for those who wish to help to concentrate at Text.Megaparsec.Combinator
module, since all combinators in that module are straightforward.
from megaparsec.
Interestingly, there seem to be some code implementing applicative interface to Parsec permutation parsers, and it comes with QuickCheck tests. I need to study the code to decide if we should ask the author of the code whether it's possible to use it in Megaparsec, possibly with some changes.
from megaparsec.
No, that code cannot be used. Parsec's permutation parser is integrated with the rest of the library, while this thing invents its own collection of combinators like optionPerm
, manyPerm
, etc. Also its tests don't use the power QuickCheck provides, they don't have any varying arguments!
My conclusion is to leave Text.Megaparsec.Perm
as is and write collection of truly generative tests for it.
from megaparsec.
I've found writing tests for Text.Megaparsec.Perm
non-trivial. At least if we want good tests. Currently I have to use custom data types to generate arguments for tests together with input for parsers. This will take longer to finish than I expected.
In addition to that it seems like error messages suck again. For example that example from documentation produces strange error messages:
p = (,,) <$?> (a', some (char a))
<||> char b
<|?> (c', char c)
QuickCheck generates the following values:
a' = ""
a = '?'
b = '!'
c' = 'a'
c = '='
And input for the parser is ?
.
Current implementation says:
Left line 1, column 1:
unexpected '?'
expecting '!' or '='
Wrong, it should be:
unexpected end of input
expecting '!'
because one '?'
is enough for some (char '?')
, but char '!'
needs also a '!'
.
It seems like this thing could use applicative interface, implemented in a decent way.
from megaparsec.
Now I see that without tests for Text.Megaparsec.Combinator
we cannot move forward to test more advanced parts of the library, since we cannot know whether it's combinators that don't work (produce low-quality error messages) or something built on top of them. I'm closing this request and going to test non-primitive combinators.
from megaparsec.
Related Issues (20)
- How to make megaparsec aware of Source Positions when using a custom token stream HOT 2
- Better error message when using `notFollowedBy` with parsers that don't partially consume input HOT 5
- Unnecessary major version bumps HOT 4
- Support text 2.0 HOT 3
- Why is `Stream s` requiring `Ord (Token s)`? HOT 8
- Consume "inline" spaces (or simply ignore spaces entirely) HOT 4
- Build failure with transformers-0.6 HOT 1
- Could megaparsec be installed with cabal 3.6 and ghc 8.10? HOT 2
- Text.Megaparsec.Byte.Lexer.decimal does not range-check HOT 2
- Text.Megaparsec.Byte.Lexer.decimal returns wrong value for Float HOT 2
- Why does `label` act only on the first set of hints? HOT 2
- Space leak in reachOffset' HOT 6
- Type class for parser monads with debugging HOT 4
- Newlines after tokens in `indentBlock` HOT 3
- Trying to understand parse error combination rules HOT 1
- Unexpected input-sharing behaviour of parsers HOT 3
- Method for adjusting subsequent parsers' errors HOT 2
- nix-shell broken on master
- takeP fails with "unexpected end of input" for negative number of tokens
- tracing-megaparsec HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from megaparsec.