Removal candidates in patterns

Simon Peyton-Jones simonpj at microsoft.com
Thu Jan 26 12:31:29 EST 2006


I agree that if (n+k) patterns go, then so should k patterns.  Both are
overloaded, and that's the root of their complexity.

Personally I think ~ patterns are great, and we are now talking about !
patterns, a kind of dual to ~ patterns.  So at least I think we should
un-couple the two discussions.

Simon

| -----Original Message-----
| From: haskell-prime-bounces at haskell.org
[mailto:haskell-prime-bounces at haskell.org] On Behalf Of
| Olaf Chitil
| Sent: 26 January 2006 17:01
| To: haskell-prime at haskell.org
| Subject: Removal candidates in patterns
| 
| 
| I am very please to see on the Wiki also a list of removal candidates
| and that these include n+k patterns and ~ patterns.
| 
| I'd like to add one pattern to this list of removal candiates: k
| patterns, that is, numeric literals.
| 
| Why do I want to get rid of these three patterns? Because all three
| caused me no end of trouble when implementing the program
transformation
| of the Haskell tracer Hat. Hat actually still doesn't handle nested ~
| patterns.
| 
| Why are these patterns so hard to implement for Hat? Surely the
Haskell
| report gives a translation into simple core Haskell. Well, Hat does
not
| use this translation because it does not want to be an inefficient
| pattern matcher (leave that job to the compiler) but produce a trace
of
| the Haskell program as it is written. However, both n+k and k patterns
| cause calls of functions ( (-), (==) etc) that Hat has to record in
its
| trace. Also ~ patterns do not fit the simple rewriting semantics of
the
| Hat trace and hence have to be recorded specially. While in simple
cases
| that occur in practice it is pretty straightforward to remove n+k, k
and
| ~ patterns from a larger pattern while keeping the rest of the larger
| pattern intact, in the general case this is incredibly hard.
| 
| Iff n+k patterns are removed, there is little good use for k patterns
| either. Since the introduction of monadic IO the ~ pattern is hardly
| used in practice either. In all the simple cases that these three are
| currently used in practice, it is easy for the programmer to define
| their function in an alternative way.
| 
| So get rid of these three and pattern matching becomes so much more
simple.
| 
| Ciao,
| Olaf
| _______________________________________________
| Haskell-prime mailing list
| Haskell-prime at haskell.org
| http://haskell.org/mailman/listinfo/haskell-prime


More information about the Haskell-prime mailing list