[Haskell] Context of a pattern variable

Stefan Holdermans sholderm at students.cs.uu.nl
Tue Jan 11 19:02:43 EST 2005


Tomasz,

> I have an idea for a funny extension to pattern matching in Haskell. I 
> wonder
> if it was proposed before, and most importantly, if it would be seen 
> as useful.

I haven't seen anything like this before, which if of course not to say 
that there has never been made a similar proposal before.

To be honest---please note that I haven't give this too much thought 
yet---I did not immediately fell in love this proposed extension. 
Surely, it makes programs shorter; but does it makes them more 
readable? Maybe it would take some time to get used to it, but I don't 
think it provides for a more intuitive coding style.

Furthermore, I think with this syntax,  it is just too easy to get 
wrong. Maybe I'm mistaken, but, to illustrate, I believe there's even 
an error in the very examples given by you:

> before:
>
>   case t of
>       (x, y, z) -> (x, y, z+1)
>
> after:
>
>   case t of
>       (_, _, ctx @> z) -> ctx z

Shouldn't that be  <code>case t of (_, _, ctx @> z) -> ctx (z + 
1)</code>?

So, for now: I'd say "no", but that's really just my opinion.

Regards,

Stefan



More information about the Haskell mailing list