prefix operators
Simon PeytonJones
simonpj at microsoft.com
Thu Jul 8 03:09:29 EDT 2010
Yes, I somewhat hacked up the rules for ! in an adhoc way. I really wanted to allow
f !x !y = (x,y)
which meant a bit of fiddling, because LHSs are parsed as terms, so this is parsed as
(f ! x) ! y
(ie as infix operators) and I have to squizzle around to reinterpret them as prefix operators. Not very cool. Something unified would be a Good Thing.
Simon
 Original Message
 From: haskellprimebounces at haskell.org [mailto:haskellprime
 bounces at haskell.org] On Behalf Of John Meacham
 Sent: 08 July 2010 00:59
 To: haskellprime at haskell.org
 Subject: prefix operators

 It occurred to me the other day that Haskell (w/ bang patterns) now has
 3 prefix operators, all of which are defined independently and follow
 their own special rules for parsing. we have (), (!) and (~).

 It would seem to me that we should somehow be able to unify the
 mechanism behind parsing these, as in practice, it seems that prefix
 operators are useful in haskell.

 We have some similarities,  and ! are both infix and prefix operators,
 ~ is not. ! and ~ can only be in patterns as prefix, () can be in both
 patterns and expressions.

 But it seems like we may be able to come up with a common way of parsing
 them all, prolog has had user defined infix, prefix, and postfix
 operators (sharing the same name even) and is still able to parse things
 properly so I don't think there will be a technical issue.

 My first impulse is to treat application as just another binary operator
 with a certain precedence and find appropriate precedences for !,~, in
 the new framework.

 note: I am not proposing user defined prefix operators, just musing
 about whether we can unify the rules behind parsing the current three
 prefix operators, perhaps folding them into the fixity resolution
 algorithm.

 John

 
 John Meacham  ⑆repetae.net⑆john⑈  http://notanumber.net/
 _______________________________________________
 Haskellprime mailing list
 Haskellprime at haskell.org
 http://www.haskell.org/mailman/listinfo/haskellprime
More information about the Haskellprime
mailing list