
Hi i can not load program test1 into hugs, but test2 works. Am i missing some special syntax? greetings, Philip -------------- test1 ------------------ foo :: Maybe Int -> Int foo Nothing =-1 foo (Just a)= a -------------- test2 ------------------ foo :: Maybe Int -> Int foo Nothing = -1 -- ^ -- +-- note an extra space foo (Just a)= a

The reason is that you can define =- as on operator so for example, in this (obfuscated) code: (=-) x y = x * y sq y = y =- y Thus, in your code, you had an operator on the LHS of the definition, and the interpreter baulked at it. Bob On 27 Sep 2005, at 10:34, feucht@uni-koblenz.de wrote:
Hi i can not load program test1 into hugs, but test2 works. Am i missing some special syntax?
greetings, Philip
-------------- test1 ------------------
foo :: Maybe Int -> Int foo Nothing =-1 foo (Just a)= a
-------------- test2 ------------------
foo :: Maybe Int -> Int foo Nothing = -1 -- ^ -- +-- note an extra space foo (Just a)= a _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Am Dienstag, 27. September 2005 11:34 schrieb feucht@uni-koblenz.de:
Hi i can not load program test1 into hugs, but test2 works. Am i missing some special syntax?
greetings, Philip
-------------- test1 ------------------
foo :: Maybe Int -> Int foo Nothing =-1 foo (Just a)= a
-------------- test2 ------------------
foo :: Maybe Int -> Int foo Nothing = -1 -- ^ -- +-- note an extra space foo (Just a)= a
Hello, obviously, Hugs thinks that =- is a special operator. In Haskell you have the ability to define your own operators, so it would be possible to define an operator =-. I would suggest that you always put spaces around the = in declarations. Best wishes, Wolfgang

On 27 Sep, Wolfgang Jeltsch wrote:
Hello,
obviously, Hugs thinks that =- is a special operator. In Haskell you have the ability to define your own operators, so it would be possible to define an operator =-. I would suggest that you always put spaces around the = in declarations.
Best wishes, Wolfgang
Hello, thank you for fast reply. Ok, but what is the semantic of '=-' ? If it's an operator, it should have some impact (right term?). Greetings, Philip _______________________________________________
Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 27 Sep 2005, at 16:53, feucht@uni-koblenz.de wrote:
On 27 Sep, Wolfgang Jeltsch wrote:
Hello,
obviously, Hugs thinks that =- is a special operator. In Haskell you have the ability to define your own operators, so it would be possible to define an operator =-. I would suggest that you always put spaces around the = in declarations.
Best wishes, Wolfgang
Hello, thank you for fast reply. Ok, but what is the semantic of '=-' ? If it's an operator, it should have some impact (right term?).
The semantics are whatever you define them to be: (=-) x y = doSomeFunkyStuff x y Note that this also introduces problems with comments, a common mistake people make is to not put a space after the -- comment symbol, so they may end up with: --| something The compiler then interprets --| as an operator. Bob

feucht@uni-koblenz.de wrote:
obviously, Hugs thinks that =- is a special operator. In Haskell you have the ability to define your own operators, so it would be possible to define an operator =-. I would suggest that you always put spaces around the = in declarations.
Best wishes, Wolfgang
Hello, thank you for fast reply. Ok, but what is the semantic of '=-' ? If it's an operator, it should have some impact (right term?).
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.
--
Glynn Clements

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. -Philip

Am Dienstag, 27. September 2005 21:54 schrieb feucht@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
participants (4)
-
feucht@uni-koblenz.de
-
Glynn Clements
-
Thomas Davie
-
Wolfgang Jeltsch