Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Inspired in part by the first draft of #651 (where the need for it arose again, which was not helped by
ReadP
s lack of discoverability), this is a parser combinator module for xmonad; based onReadP
, but hopefully a bit more intuitive to use. This is especially with regards to how other combinator libraries work, as well as the interplay with normalControl.Applicative
functions. Plus,Semigroup
andMonoid
instances :)Commits
New module: XMonad.Util.Parser
This module provides a parser combinator library based on base's ReadP,
which aims to function more like other popular combinator libraries like
attoparsec and megaparsec.
In particular, the Alternative and Monoid instances are left-biased now,
so combinators like
many
andoptional
from Control.Applicative workin a more intuitive manner. Further, some functions (like
endBy1
)only return the "most successful" parse, instead of returning all of
them. We can now get away with providing a single parsing result
instead of ReadP's list of results (as such, parsers need to be
disambiguated earlier instead of trimming the list down after parsing).
X.P.OrgMode: Use X.U.Parser
Since we now have an "internal" parser library in xmonad, use it. This
allows us to get rid of some hacks in this module that were needed
because of ReadP's parsing behaviour.
X.U.EZConfig: Use X.U.Parser
Using X.U.Parser works almost as a drop-in replacement for ReadP here.
In some places (like
parseSpecial
) we need to be a little bit morecareful when constructing the parser, but this is offset a much simpler
readKeySequence
.X.U.EZConfig: Add simple unit tests
Add very basic unit tests for EZConfig to see if it can parse all of the
keys (and key combinations) that it promises to parse.
The long-term goal here should be to write a pretty-printer for EZConfig
and to check whether that's a proper inverse (either in the normal sense
or in the inverse semigroup sense), as the tests for X.P.OrgMode do.
Checklist
I've read CONTRIBUTING.md
I've considered how to best test these changes (property, unit,
manually, ...) and concluded:
I updated the
CHANGES.md
file