The module Core contains the basic functionality of the parser library.
It uses the breadth-first module to realise online generation of results, the error
correction administration, dealing with ambigous grammars; it defines the types of the elementary parsers
and recognisers involved.For typical use cases of the libray see the module Text.ParserCombinators.UU.Examples

The module Control.Applicative contains the definition for <$ which cannot be changed .
Since we want to give optimised implementations of this combinator, we hide its definition, and define a class containing its signature.

Many parsing libraries do not make a distinction between the terminal symbols of the language recognised and the
tokens actually constructed from the input. This happens e.g. if we want to recognise an integer or an identifier: we are also interested in which integer occurred in the input,
or which identifier.

The function pSym takes as argument a value of some type symbol, and returns a value of type token. The parser will in general depend on some
state which is maintained holding the input. The functional dependency fixes the token type, based on the symbol type and the type of the parser p.
Since pSym is overloaded both the type and the value of symbol determine how to decompose the input in a token and the remaining input.
pSymExt is the actual function, which takes two extra parameters: one describing the minimal numer of tokens recognised,
and the second whether the symbol can recognise the empty string and the value which is to be returned in that case

The first parameter to pSymExt is a Nat which describes the minimal numer of tokens accepted by this parser. It is used in the abstract interpretation
which computes this property for each parser. It's main use is in choosinga non-recursive alternative in case a non-terminal has to be inserted.
The second parameter indicates whether this parser can also skip recognising anything and just return a value of type a, hence a `Maybe a`

The function splitStae playes a crucial role in splitting up the state. The symbol parameter tells us what kind of thing, and even which value of that kind, is expected from the input.
The state and and the symbol type together determine what kind of token has to be returned. Since the function is overloaded we do not have to invent
all kind of different names for our elementary parsers.

Additional useful combinators

The parsers build a list of symbols which are expected at a specific point.
This list is used to report errors.
Quite often it is more informative to get e.g. the name of the non-terminal.
The <?> combinator replaces this list of symbols by it's righ-hand side argument.

pSwitch takes the current state and modifies it to a different type of state to which its argument parser is applied.
The second component of the result is a function which converts the remaining state of this parser back into a valuee of the original type.

Maintaining Progress Information

The data type Steps is the core data type around which the parsers are constructed.
It is a describes a tree structure of streams containing (in an interleaved way) both the online result of the parsing process,
and progress information. Recognising an input token should correspond to a certain amount of Progress,
which tells how much of the input state was consumed.
The Progress is used to implement the breadth-first search process, in which alternatives are
examined in a more-or-less synchonised way. The meaning of the various Step constructors is as follows:

A correcting step has to made to the input; the first parameter contains information about what was expected in the input,
and the second parameter describes the various corrected alternatives, each with an associated Cost

Auxiliary functions and types

The function checks wehther its second argument is a parser which can recognise the mety sequence. If so an error message is given
using the name of the context. If not then the third argument is returned. This is useful in testing for loogical combinations. For its use see
the module Text>parserCombinators.UU.Derived

This function is similar to the above, but can be used in situations where we recognise a sequence of elements separated by other elements. This does not
make sense if both parsers can recognise the empty string. Your grammar is then highly ambiguous.

The data type Nat is used to represent the minimal length of a parser.
Care should be taken in order to not evaluate the right hand side of the binary functions nat_min and `nat-add` more than necesssary.