[Haskell-cafe] newbe question

Wolfgang Jeltsch wolfgang at jeltsch.net
Wed Sep 28 08:21:24 EDT 2005


Am Dienstag, 27. September 2005 21:54 schrieb feucht at uni-koblenz.de:
> On 27 Sep, Glynn Clements wrote:
> > It isn't defined in the prelude or any of the standard libraries.
> >
> > The point is that the Haskell tokeniser treats any consecutive
> > sequence of the symbols !#$%&*+./<=>?@^|-~ as a single operator token.
> > This occurs regardless of whether a definition exists for the
> > operator.
> >
> > More generally, the tokenising phase is unaffected by whether or not
> > an operator, constructor, identifier etc is defined. A specific
> > sequence of characters will always produce the same sequence of tokens
> > regardless of what definitions exist.
>
> Thank you,
> that is the problem i am wrestling with.

The point is that in Haskell the set of operators is not fixed as it is in C, 
C++, Java etc.  An operator in Haskell is similar to an identifier.  The 
tokenizer or parser doesn't know which identifiers are defined at a certain 
point and which are not.  It treats everything that looks like an identifier 
and is not a reserverd word as an identifier.  In the same way, it treats 
every sequence of punctuation which is not reserved (like =, :: or -> is) as 
an operator.  This is a very reasonable behavior.

> -Philip

Best wishes,
Wolfgang


More information about the Haskell-Cafe mailing list