Re: cannot define operators

From: Wolfgang Lux <wlux_at_uni-muenster.de>
Date: Wed, 24 Apr 2013 14:33:31 +0200

Wolfgang Jeltsch wrote:

> Am Mittwoch, den 24.04.2013, 09:36 +0200 schrieb Björn Peemöller:
>> Am 23.04.2013 18:42, schrieb Wolfgang Jeltsch:
>>> Hello,
>>>
>>> the following code is not accepted by KiCS2:
>>>
>>>> (-->) :: Int -> Int -> Bool
>>>> n --> m = n <= m
>>>
>>> It is valid Haskell at least, but KiCS2 says:
>>>
>>>> Bug.curry, line 2.1:
>>>> operator symbol expected
>>>
>>> Is this a bug?
>>
>> Hello Wolfgang,
>>
>> in Curry [^1] line comments start with "--", in contrast to Haskell
>> where they start with "--{-} ". Therefore, striping of the comments, the
>> remaining code is
>>
>> (
>> n
>>
>> Because of the opening parenthesis, the frontend now expects an operator
>> symbol.
>>
>> [^1]: Defined on p. 67 of the Curry Report 0.8.3.
>
> Hello Björn,
>
> thanks for the explanation. I hope it’s okay that I reply to the list.
>
> What do you mean by “--{-}”? As far as I know, the point with Haskell is
> that tokenization is done before stripping comments, so that --> is not
> treated as the start of a comment, since the -- is not a token on its
> own, but part of the token -->.
>
>> The quick fix is of course to simply change the operator name, but one
>> could also ask the question why Curry has a different line comment syntax.
>
> Indeed. :-)

Just a bit of history. Haskell used to have the same convention as Curry, i.e., two consecutive dashes at the start of a token would always begin a line comment. AFAIR, this was changed for the Revised Haskell 98 report, but nobody cared to update Curry's lexical syntax at that point. I agree that it would be a good idea for Curry to follow Haskell's current rules.

Wolfgang


_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Wed Apr 24 2013 - 15:47:03 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 19 2019 - 07:15:09 CEST