Re: cannot define operators

From: Björn Peemöller <bjp_at_informatik.uni-kiel.de>
Date: Wed, 24 Apr 2013 16:32:40 +0200

Am 24.04.2013 12:04, schrieb Wolfgang Jeltsch:
> 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.

That's great, I also intended to do so but must have clicked the wrong
button ;)

> What do you mean by “--{-}”?

I wanted to state that two or more dashes start a line comment, but this
is only half of the story. The current Haskell 2010 report says:

comment ::= dashes [ any<without_symbol> { any } ] newline
dashes ::= --{-}

So one could say that two or more dashes start a line comment *except
when they are directly followed by a symbol character*.

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

I'm not sure how the different implementations perform the lexing, but
regardless whether they support comment tokens or not the above
mentioned grammar recognizes "-->" as an operator token. Sorry for the
inaccuracy!

Regards,
Björn
_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Mi Apr 24 2013 - 17:01:55 CEST

This archive was generated by hypermail 2.3.0 : Do Jun 20 2024 - 07:15:12 CEST