Remove implicit space parsing from combinators#2
Conversation
- `many` and `some` do not implicitly parse spaces any more - use `spacy` to parse spaces around a parser - use `by` to parse items separated by something - use this for the old behaviour: `some_old item == by spaces item`
|
Hi @timjs ! First of all, thank you for your feedback. I think renaming I also have some refactoring / cleaning-up planned over the next week-end so I might wait until then to review and merge your changes. (I hope it's not too inconvenient for you to wait until then for a new release). |
|
|
||
| {-| Apply a parser one or more times and return a list of the results. | ||
| -} | ||
| some : Parser a -> Parser (List a) |
There was a problem hiding this comment.
Having some return a Parser (a, List a) was very much intentional as to retain type safety.
Basically, (a, List a) represents a type-safe non-empty list which enables the use of some safe versions of head, tail or even a foldl/foldr with no need for an initial value.
If there is a use case for some returning only a List a, I guess we could implement it separately.
|
I reviewed some of your changes and made a few comments. I'm also in the process of writing test cases for every exposed function in those modules and adding a travis.ci config, so I would advise to wait for these to hit and then update your branch. |
|
Alright, I added the Travis CI integration as well as (some) tests. @timjs could you please rebase your branch on top of |
|
Yes I’ll do that! Think I’ll have some time this afternoon.
…On 20 Sep 2018, 11:41 +0200, Hugo Saracino ***@***.***>, wrote:
Alright, I added the Travis CI integration as well as (some) tests.
@timjs could you please rebase your branch on top of master before making changes and verifying that tests still pass ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
Fixed the type of |
|
That's a valid point ! I considered using My current position on this matter is that I don't want to tie this library to any superfluous dependency nor users to any single implementation. It should be easy for them to convert the simple It's debatable but for the time being, I prefer sticking with the generic |
|
Also, I'm starting to wonder if it wouldn't be more clear to implement I don't know if the following would be a performance hit (I should probably try benchmarking it) : many : Parser a -> Parser (List a)
many item =
sequence
{ start = ""
, separator = ""
, end = ""
, spaces = spaces
, item = item
, trailing = Forbidden
} |
|
I'm not sure if |
|
Yeah, I did it just now. Replacing the original Although those might not be that exhaustive yet. |
|
For reference, here is the implementation of |
|
Anyway, sorry for the digression, that's a discussion for further down the road. @timjs for now, and to summarize, could you please revert the change to |
|
I also renamed |
|
Some tests obviously fail, because they depend on |
Hi @Punie!
I like this package contains some classical combinators as
some,manyandbetween. However, they hardcode items should be separated by spaces. In the most general case, this is not needed. I propose the following changes, implemented by this pull request:manyandsomedo not implicitly parse spaces any morespacyto parse spaces around a parserbyto parse items separated by somethingsome_old item == by spaces itemAlso, to be consistent with other extra-packages, like those published by elm-community, the module exporting these functions should be called
Parser.Extrainstead ofParser.Extras. Above proposed changed imply a semantic change, and therefore a major bump, I also changed the name of the module by removing the plural "s".What do you think of these changes?