[Haskell] View patterns in GHC: Request for feedback

Barney Hilken b.hilken at ntlworld.com
Thu Jul 26 17:14:06 EDT 2007

I think you should add the form:

(function -> pattern) @ pattern

as well. The reason you don't need general 'pattern @ pattern' with  
normal patterns is that, if anything is going to match, the two  
patterns must have the same outermost constructor, so you can push  
the @ inside. This doesn't hold for view patterns, and you might well  
want to match against several views.

Of course you can do this with 'both', but the readability is  
terrible, especially if you want to match against more than two  
patterns. Nested 'both' gets extremely long, or do you want to define  
'allThree', 'allFour', ...

The reason I think this might be important is that you could use view  
patterns for records:

(label1 -> x)@(label2 -> y)@(label3 -> z) ...

gives a reasonable syntax for a record pattern, and it would be  
compatible with any form of extensible records.


More information about the Haskell mailing list