Git Product home page Git Product logo

replace-megaparsec's People

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

Watchers

 avatar  avatar  avatar  avatar

replace-megaparsec's Issues

"non-greedy" parser combinator

A parser combinator which is like many except non-greedy.

manyNongreedy 
  :: ParserT e s m a -- ^ parse this as few times as possible
  -> ParserT e s m b -- ^ parse the rest of the input
  -> ParserT e s m ([a],b)
manyNongreedy p rest = undefined

The obvious way to implement this is to try to parse rest, and if if fails then backtrack and parse one p, then try to parse rest again, et cetera. Not super performant, but maybe very useful.

Some discussion:
https://www.reddit.com/r/haskell/comments/3b4ztr/a_neat_way_of_doing_nongreedy_parsing_with_parsec/

Oh this is exactly the same as manyTill_.

sepCap docs output

Output constraints not expressed in the type system:

The output list will not be empty. If the input is the empty string then the output will be [Left ""].

The output list will not contain two consecutive Lefts.

The output list may contain two consecutive Rights.

test parser fail

Make sure we test that the parser will continue in event of a parse that
fails on an operation like read.

Bounds for dependencies seem incorrect

The Cabal file for replace-megaparsec states simply that megaparsec is a dependency, but that seems incorrect: in fact, versions of megaparsec will have to at least be >= 7.0.0 to work.

This because the code for replace-megaparsec uses the anySingle function, introduced in megaparsec 7.0.0.

Thus, the Cabal file should give the dependency as:

    , megaparsec >= 7.0.0

(The bounds might in fact be tighter than that; I haven't checked whether megaparsec 7.0.0 will in fact work.)

anyTill

Like manyTill_, but specialization allows for efficient capture of the preceding string.

Acts like a takeWhile which is predicated beyond just the next token. Be careful not to look too far ahead; if the end parser looks to the end of the input then anyTill will be O(NĀ²).

https://hackage.haskell.org/package/megaparsec-8.0.0/docs/Text-Megaparsec.html#v:takeWhileP

https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html#v:takeWhile

end may be a zero-consumption parser (combine with lookahead), in which case after anyTill succeeds, then the parser input state will be at the beginning of the place where end matched.

haddock megaparsec links

Make sure that Text.Megaparsec.match and Text.Megaparsec.Stream are properly linked in the haddock that is generated on Hackage.

utility functions

doesMatchExist = case (sepCap sep input) of
    [Left _] -> False
    otherwise -> True

Does laziness short-circuit doesMatchExist correctly?

firstMatch = find isRight $ sepCap sep input

Does laziness short-ciruit firstMatch correctly?

Prelude.undefined with a build executable.

Hi, I have some bizarre behaviour that I pushed to this repository.

https://github.com/locallycompact/replace-megaparsec-bug

I am on NixOS so my commands are with --nix

If I build with stack --nix build and then run stack --nix exec -- replace-megaparsec-bug-exe I get a callstack with Prelude.undefined.

[I] lc@aiur ~/replace-megaparsec-bug (master)> 
stack --nix build && stack --nix exec -- replace-megaparsec-bug-exe
replace-megaparsec-bug-exe: Prelude.undefined
CallStack (from HasCallStack):
  error, called at libraries/base/GHC/Err.hs:80:14 in base:GHC.Err
  undefined, called at src/Replace/Megaparsec.hs:211:21 in replace-megaparsec-1.4.2.0-8z2kgUAlSuYEyo1NOrKi1C:Replace.Megaparsec

However if I run the executable ./Script.hs as a stack script with the exact same content, it executes and returns.

[I] lc@aiur ~/replace-megaparsec-bug (master)> ./Script.hs 
[]

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.