
Hello, Are there any plans to extend Haskell parser to support prefix and postfix operators? It will be just great for domain-specific languages. It always kind of bothered me that unary minus is special. Thanks, Eugene

"Eugene Nonko"
Are there any plans to extend Haskell parser to support prefix and postfix operators? It will be just great for domain-specific languages.
We already have prefix operators, don't we? I.e., regular functions are prefix? One would assume (but one would also be to lazy to try it) that operators (i.e. non-alpha identifiers) could be defined unary, and applied with the parenthesis notation? E.g. (%&/) :: a -> b (%&/) x = ...
It always kind of bothered me that unary minus is special.
I've rather felt that unary minus should go, I almost always end up using "negate" explicitly, anyway. -kzm -- If I haven't seen further, it is by standing in the footprints of giants

G'day all. On Thu, Aug 28, 2003 at 11:05:52AM +0200, Ketil Z. Malde wrote:
We already have prefix operators, don't we? I.e., regular functions are prefix?
Not really. This: - sqrt x Doesn't mean the same thing as this: negate sqrt x I think the difficulty is that it's very hard to convert a general operator grammar into a context-free grammar, particularly if you can set precedences and associativities at run-time. See, for example: http://citeseer.nj.nec.com/aasa91precedences.html Effectively you end up writing a whole other parser just to handle operators. Cheers, Andrew Bromage

Dnia śro 27. sierpnia 2003 20:48, Eugene Nonko napisał:
Are there any plans to extend Haskell parser to support prefix and postfix operators? It will be just great for domain-specific languages. It always kind of bothered me that unary minus is special.
Having only infix operators has the advantage that operators are never adjacent to other operators, so you don't need extra spaces just to separate them nor complicated lexical conventions which tell where multi-character operator sequences should be split. Especially as prefix and postfix operators look better without spaces. In Haskell there are rare troubles because of - and ~ (lazy patterns). ! (strictness annotations) happens not to be used adjacent to operators. I think there are no more unary operators, so it's almost safe; problematic cases with - and ~ are really rare. -- __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/
participants (4)
-
Andrew J Bromage
-
Eugene Nonko
-
ketil@ii.uib.no
-
Marcin 'Qrczak' Kowalczyk