parsec
parsec copied to clipboard
the name of `notFollowedBy` is not consistent with the semantics of the other parsers
Just a small thing if you want, i'm pointing this out while approaching Parsec, before getting used to this.
Usually a parser's name refers to the current parser input. char 'a'
will parse 'a'
and so on.
If we read notFollowedBy
with the same semantics, a parser like notFollowedBy '.'
should correctly parse "."
because "."
is not followed by a dot. It should fail for "a.", instead.
In this sense a parser called notFollowedBy
should probably get two parsers as arguments, like manyTill
etcetera. I find that the current semantic of notFollowedBy
is closer to a simple not
.
I think that you are right, but modifying it might cause a lot of problem and bugs in projects that use it because this new behavior would be different.
I am not sure that modifying notFollowedBy
is a good idea.
Thanks for following up @barufa. First of all we can agree whether we like the interface or whether we think that there is room for improvement. Once we agree that we want to improve, we can find a way towards it. For example an alias of notFollowedBy
could be introduced and, if we like the resulting semantic, notFollowedBy
could be deprecated in a couple of years. Even if no change is going to happen, it can be helpful to discuss about the clearest semantic so that other function names can follow a schema and the parser can become more approachable. First of all let's wait for more people to chime in :)