prefix operators

Atze Dijkstra atze at cs.uu.nl
Thu Jul 8 04:12:32 EDT 2010


For expressions operator sections will also be difficult to deal with, i.e. the expression (!x) could either be a parenthesized prefix !, or a section for binary !. Some disambiguation mechanism would be required. Currently such disambiguation is hardcoded for - as a special case in the grammar.

	Atze

On  8 Jul, 2010, at 09:09 , Simon Peyton-Jones wrote:

> Yes, I somewhat hacked up the rules for ! in an ad-hoc 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 re-interpret them as prefix operators.  Not very cool.  Something unified would be a Good Thing.
> 
> Simon
> 
> 
> 
> | -----Original Message-----
> | From: haskell-prime-bounces at haskell.org [mailto:haskell-prime-
> | bounces at haskell.org] On Behalf Of John Meacham
> | Sent: 08 July 2010 00:59
> | To: haskell-prime 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/
> | _______________________________________________
> | Haskell-prime mailing list
> | Haskell-prime at haskell.org
> | http://www.haskell.org/mailman/listinfo/haskell-prime
> 
> _______________________________________________
> Haskell-prime mailing list
> Haskell-prime at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-prime


                - Atze -

Atze Dijkstra, Department of Information and Computing Sciences. /|\
Utrecht University, PO Box 80089, 3508 TB Utrecht, Netherlands. / | \
Tel.: +31-30-2534118/1454 | WWW  : http://www.cs.uu.nl/~atze . /--|  \
Fax : +31-30-2513971 .... | Email: atze at cs.uu.nl ............ /   |___\





More information about the Haskell-prime mailing list