Re: [Haskell-cafe] newbe question

2005-09-28 Thread Wolfgang Jeltsch
Am Dienstag, 27. September 2005 21:54 schrieb [EMAIL PROTECTED]:
 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 !#$%*+./=[EMAIL PROTECTED]|-~ 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
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] newbe question

2005-09-27 Thread feucht
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


Re: [Haskell-cafe] newbe question

2005-09-27 Thread Thomas Davie

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, [EMAIL PROTECTED] 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





___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] newbe question

2005-09-27 Thread Wolfgang Jeltsch
Am Dienstag, 27. September 2005 11:34 schrieb [EMAIL PROTECTED]:
 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
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] newbe question

2005-09-27 Thread feucht
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

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] newbe question

2005-09-27 Thread Thomas Davie


On 27 Sep 2005, at 16:53, [EMAIL PROTECTED] 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

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] newbe question

2005-09-27 Thread Glynn Clements

[EMAIL PROTECTED] 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 !#$%*+./=[EMAIL PROTECTED]|-~ 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 [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] newbe question

2005-09-27 Thread feucht
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 !#$%*+./=[EMAIL PROTECTED]|-~ 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
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe