‘Text.Megaparsec.Prim’ cannot be considered portable since it uses
multi-parameter type classes and functional dependencies.
Other modules that depend on these non-portable features from
‘Text.Megaparsec.Prim’ should be considered non-portable too.
Closes#37.
Most part of these changes is proposed by @neongreen. To apply precisely
what I deem acceptable, correct some of them in other way, and add some
other things, I've manually re-edited this.
Closes#38.
Now tab width can be manipulated with via the following functions:
* ‘getTabWidth’
* ‘setTabWidth’
Other auxiliary changes were performed, such as updating of
‘updatePosChar’.
This also corrects a bit obsolete descriptions of some functions.
Closes#36.
We should try to preserve original information where possible. User then
can convert case of parsed string if necessary. Previous implementation
discarded actually parsed string and returned argument of the
function — this can be considered as data loss of a sort.
Closes#35.
Since ‘many’ (and thus ‘some’) are the only combinator that can succeed
consuming input and produce hints at the same time we can conclude that
‘cok'’ continuation in ‘pLabel’ combinator is only called when ‘many’ is
labelled. By correcting label in this case prepending the phrase “rest
of ” to actual label we can greatly improve result error message.
Close # 27.
Backtracking user state can be achieved via combination of ‘StateT’
monad transformer and ‘ParsecT’:
StateT StateType (ParsecT s m a)
This user state can be more flexible. This fact renders current built-in
user state redundant.
To help work with this new approach (combining monad transformers more
freely) we introduce ‘MonadParsec’ MTL-style type class. All tools that
come with Megaparsec library were modified to work smoothly with any
instance of ‘MonadParsec’, not only ‘ParsecT’.
Now all the combinators in ‘Text.Megaparsec.Combinator’ are defined for
any instance of ‘Control.Alternative’ (sometimes ‘Control.Applicative’).
Some combinators are inlined.
Closes#29.
Now testing function can return ‘Either [Message] a’ so it can construct
full list of error messages. This may be useful in some cases when
tokens are more complex than simple characters.
Multi-character operators should use ‘try’ in order to be reported
correctly (as “operator”). I've mentioned it in doc-string of
‘makeExprParser’.
It's tempting to include ‘try’ directly in expression parsing code, but
following general spirit of Parsec toward ‘try’, I think current
solution is the best.
Various languages may vary in how hexadecimal and octal literals should
be prefixed. Following the spirit of the new lexer we leave this to
programmer to decide.
Eliminated ‘Text.Megaparsec.Language’ module because at this point it is
clear that already existing definitions are of little use in
Megaparsec. I started writing “default” language definition in
‘Text.Megaparsec.Lexer’.
At this point it should be possible to parse languages where indentation
matters, although we will need to provide more helpers to make it
easier.
Obviously order does matter here, since ‘Monoid’ instance for ‘Hints’ is
derived from [], so (<>) is the same as (++) and we should be careful
to keep things in the right order.
These parsers are considered deprecated:
* ‘chainl’
* ‘chainl1’
* ‘chainr’
* ‘chainr1’
* ‘sepEndBy’
* ‘sepEndBy1’
Apart from this, the commit includes various cosmetic changes in
module ‘Text.Megaparsec.Combinator’.
The following functions and data types have been renamed:
* ‘permute’ → ‘makePermParser’
* ‘buildExpressionParser’ → ‘makeExprParser’
* ‘GenLanguageDef’ → ‘LanguageDef’
* ‘GenTokenParser’ → ‘Lexer’
* ‘makeTokenParser’ → ‘makeLexer’