<div dir="ltr">Pattern match in a function definition is different. Here the pattern match is actually being used as part of the function definition.  We were trying to figure out the usefulness of non-function pattern matches which do not result in a binding. The assert case pointed out by Brandon is one example. Though not so useful.<div><br></div><div>-harendra<br><div class="gmail_extra"><br><div class="gmail_quote">On 24 February 2017 at 10:30, Taeer Bar-Yam <span dir="ltr"><<a href="mailto:taeer@necsi.edu" target="_blank">taeer@necsi.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Since nobody has provided an example use case, I will. It's not particularly useful, but it's a minimal case that does something interesting.<br>
<br>
func :: (Int, a) -> Maybe a<br>
func (0, x) = Just x<br>
func _ = Nothing<br>
<br>
Excerpts from Brandon Allbery's message of February 23, 2017 10:51 pm:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Without a binding it is useless at top level, but if you strictify the<br>
pattern it can be useful in `let` (possibly as a sanity check where you<br>
want the program to abort if it fails). I don't recall offhand if it<br>
desugars usefully in list comprehensions, but if so it would work as a<br>
filter. There may also be other specialized use cases; general syntax tends<br>
to get reused a lot in Haskell, so making this case a syntax error could<br>
make it difficult to support actually useful cases. :)<br>
<br>
(Also I'm sure someone overly clever could figure out some way to abuse it.<br>
:)<br>
<br>
On Thu, Feb 23, 2017 at 10:41 PM, Harendra Kumar <<a href="mailto:harendra.kumar@gmail.com" target="_blank">harendra.kumar@gmail.com</a>><br>
wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 24 February 2017 at 08:45, Brandon Allbery <<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Literally the only use I've seen for this was a CCC puzzle. However, it<br>
is the trivial case of something that is more useful: pattern matching the<br>
result of an expression (say, a Data.Map.lookup when you know the key<br>
exists).<br>
<br>
</blockquote>
<br>
Can you explain how that will be useful (without a binding)? Will the<br>
pattern match be ever actually tried when there is no binding?<br>
<br>
-harendra<br>
<br>
</blockquote>
<br>
<br>
<br>
-- <br>
brandon s allbery kf8nh                               sine nomine associates<br>
<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>                                  <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a><br>
unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" rel="noreferrer" target="_blank">http://sinenomine.net</a><br></div></div>
______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/haskell-caf<wbr>e</a><br>
Only members subscribed via the mailman list are allowed to post.<span class="HOEnZb"><font color="#888888"><br>
</font></span></blockquote><span class="HOEnZb"><font color="#888888">
<br>
 --Taeer</font></span></blockquote></div><br></div></div></div>