<div dir="ltr"><div>Hi Jan,<br><br>What you&#39;re suggesting is called &quot;non-linear patterns&quot;, and it&#39;s a perfectly sensible, well-defined feature in a language with pattern-matching. As you point out, non-linearity allows for more direct &amp; succinct programming. I&#39;ve often wished for this feature when writing optimizations on data types, especially for syntactic types (languages).<br>

<br>As Ivan mentioned, there is some danger that people may accidentally a non-linear pattern accidentally, and perhaps the early Haskell designers chose the linearity restriction out of this worry. The importance of such dangers is a subjective call, and certainly not one carried out consistently in Haskell. Consider, for instance, the choice that let &amp; where bindings are recursive by default in Haskell, unlike ML and Lisp. I like this choice, but I can understand objections that it leads to accidental recursions, especially for non-functions.<br>

<br><br></div>-- Conal<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 8, 2013 at 6:11 AM, Jan Stolarek <span dir="ltr">&lt;<a href="mailto:jan.stolarek@p.lodz.pl" target="_blank">jan.stolarek@p.lodz.pl</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">&gt; You can achieve something similar with the ViewPatterns language<br>
&gt; extension.<br>
&gt;<br>
</div><div class="im">&gt; member _ [] = False<br>
&gt; member x (((x ==) -&gt; True) : _) = True<br>
&gt; member x (_ : xs) = member x xs<br>
</div>Hi Tillmann,<br>
<br>
there are a couple of ways to achieve this in Haskell, for example using guards:<br>
<div class="im"><br>
member :: Eq a =&gt; a -&gt; [a] -&gt; Bool<br>
member _ []             = False<br>
</div>member y (x:_) | x == y = True<br>
member y (_:xs)         = member y xs<br>
<br>
The goal of my proposal is to provide a concise syntax, whereas ViewPatterns are very verbose and<br>
guards are slightly verbose. I want something simple and something that is very intuitive if<br>
you&#39;ve programmed in Prolog :)<br>
<br>
Janek<br>
<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br></div>