Giter VIP home page Giter VIP logo

idris-tparsec's Introduction

TParsec - Total Parser Combinators in Idris

This is a port of agdarsec to Idris.

idris-tparsec's People

Contributors

andrevidela avatar clayrat avatar gallais avatar marcosh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

idris-tparsec's Issues

Port to Idris2

I've pushed an initial attempt to the idris2 branch, the core library itself seems to compile (at least with the latest master version), but the examples still need some work.

Boxed combinators?

Using combinators on rec appears to be fairly common, and it seems to always require defining helpers to make types align, e.g.:

andbox : All (Box (Parser' s) :-> Box (Parser' t) :-> Box (Parser' (s, t)))
andbox {s} {t} p q = map2 {a=Parser' s} {b=Parser' t} (\p, q => and p q) p q

nelistbox : All (Box (Parser' s) :-> Box (Parser' (NEList s)))
nelistbox {s} p = map {a=Parser' s} nelist p

Should we maybe provide a separate module for these out of the box :), or there's a more elegant solution?

Add docs to SLTC example a la Arithmetic example

Background

I am very excited about this library. A couple years ago I was all into parser combinators and tried using Lightyear. It made all my functions partial and my program crashed and I had no idea why. I searched around until I found the Agda paper (which I guess you wrote) but was out of energy and gave up. It was beyond me at the time; I was only beginning to put effort toward reading papers. I developed a style for writing total parsers in Idris without combinators. It was heavy on boilerplate but I was that committed to totality. I would write that way even in F#. In many ways I would say the purpose of dependent types is to enable totality.

So I was very excited to see that you had ported your stuff to Idris. I read your Arithmetic example and it was very helpful. I am going to try to read the paper now.

Request

If you wouldn't mind, I would love to see the STLC example documented in the style of the Arithmetic example docs. I would really like to grok and internalize what you've done here but my CS degree didn't prepare me at all for understanding academic computer science so I've been working to understand it on my own time because I have a great hunger for it.

Thank you for making this library.

Buggy STLC example?

While working on https://github.com/gallais/agdarky I've noticed that the parser for STLC I had did
not work on examples of the form \f.\a.\b. f a b which would get parsed as
\f.\a.\b. f (a b) rather than \f.\a.\b. (f a) b.
I have pushed a fix on agdarky but haven't had the time to look back at the example
we have here (and in the agdarsec repo).

The idea behind the fix amounts to:

  • the head of the neutral term is either a variable, a cut or an infer between parentheses
  • each argument is either a variable or a whole checkable term in parentheses

Is DecEq necessary for tokens?

As far I see, the DecEq constraint on tokens is only used in Combinators.exact, where it is immediately converted to a boolean. Seems like a weaker Eq constraint could be used here, sparing the user of writing things like counterproofs. Is this an artifact of an Agda port, or did you intend to have this constraint?

Error reporting

This currently seems to be the biggest feature missing from TParsec. Do you have any suggestions on how to implement this better? Maybe by changing the Success structure to be a variant type Result = Error | Success?

Compile error in recordChar: No such variable ignore

Hi, I stumbled upon the following problem when compiling (@clayrat):

erik@munin:~/dev/3rdparty/idris-tparsec (master) $ idris --build TParsec.ipkg
Entering directory `./src'
Type checking ./Relation/Indexed.idr
Type checking ./Relation/Subset.idr
Type checking ./Induction/Nat.idr
Type checking ./Data/SizedDict.idr
Type checking ./Data/Inspect.idr
Type checking ./Data/DList.idr
Type checking ./Data/NEList.idr
Type checking ./TParsec/Result.idr
Type checking ./TParsec/Success.idr
Type checking ./TParsec/Types.idr
./TParsec/Types.idr:109:16-56:
    |
109 | recordChar c = MkTPT $ ignore (modify (mapFst (next c)))
    |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When checking right hand side of recordChar with expected type
        TParsecT e a m ()

When checking argument runTPT to constructor TParsec.Types.MkTPT:
        No such variable ignore

Adding a .ipkg file?

Please add a .ipkg file for ease of installation an building. It would make using your library more convenient.

Return bounded nats for `decimalDigit`

At the moment decimalDigit in TParsec.Combinators.Numbers returns a Nat
when it should return a Nat together with the proof it is less than 10.
I don't think it's worth using Fin here as we do want natural numbers in the
other parsers using decimalDigit.

Add various `parse` functions

The one function in TParsec.Running is only ever useful to write down
examples but not to actually use it. It'd be nice to have specialised runners
for input String vs. Text and output Maybe a or List a.

Experiment with `Lazy` annotations

I am not sure how much of the time spent parsing examples is actually spent
computing the whole Parser mn p a n for the concrete size n of the input
string. If this is indeed happening then we ought to be able to save a lot of
time by adding Lazy annotations for the second arguments of and, alt, etc.

Add JSON parser

It's so ubiquitous it probably makes sense to have an implementation out of the box.

Bug in the string literal parser?

While I was porting the JSON parser to Agda yesterday I think I have
found a bug in the string literal parser:

$ rand (char '\\')
$ box $ andoptbind anyTok $ \ c =>
if c /= into 'u' then fail else unicode

After having read a \ we will only accept a u followed by 4 hexadecimal
digits aka. a unicode character. Shouldn't we also accept:

  • another \
  • a "
  • a r, n, or t
    ?

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.