patch applied (haskell-prime-status): BangPatterns: probably accept ==> undecided

Simon Marlow marlowsd at gmail.com
Mon Apr 21 14:38:51 EDT 2008


John Meacham wrote:
> On Fri, Apr 18, 2008 at 08:36:42AM +0100, Simon Peyton-Jones wrote:
>> Not allowing infix functions on the LHS would be a notable
>> simplification.  Constructors in patterns should still be infix of
>> course: f (a :=: b) = ...
> 
> I don't know, I think this will confuse things, especially for newbies,
> people tend to say things like:
> 
> a + b = foo
> 
> as "a plus b is foo", and so would probably naturally write it in infix
> form, it would be a source of confusion if the compiler didn't accept
> it.
> 
> I don't think saying ~ and ! are operators unless they 
> 
> 1. immediately followed  by a '(', a letter, or an underscore
> 2. are preceded by whitespace or BOL
> 
> is that onerous. 

I don't like the idea of solving this in the lexical syntax, e.g. by the 
rules you gave above, it's just too ad-hoc.  I think a better way to fix 
it is just to disallow infix declarations of !, ~ (and @ ?).  Currently 
the grammar has:

funlhs 	 -> 	 var apat {apat}
	| 	pati+1 varop(a,i) pati+1
	| 	lpati varop(l,i) pati+1
	| 	pati+1 varop(r,i) rpati
	| 	( funlhs ) apat {apat}

so we can use a restricted variant of varop that doesn't include !, ~ or 
@ (well, varop doesn't currently include ~ or @, but I assume we want it 
to - it would be similar to the way "hiding" is handled now).

Incedentally I think we should use a different operator for array 
indexing, because ! is almost universally used to mean "strict" now: in 
bang patterns, strict datatype fields, and $!.  See

http://hackage.haskell.org/trac/haskell-prime/wiki/ArrayIndexing

Cheers,
	Simon



More information about the Haskell-prime mailing list