GithubHelp home page GithubHelp logo

Comments (5)

mrkkrp avatar mrkkrp commented on May 31, 2024

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.

mrkkrp avatar mrkkrp commented on May 31, 2024

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.

mrkkrp avatar mrkkrp commented on May 31, 2024

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.

mrkkrp avatar mrkkrp commented on May 31, 2024

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.

mrkkrp avatar mrkkrp commented on May 31, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.