<div dir="ltr">An idea: could we perhaps use the same syntax as for MINIMAL pragmas also for COMPLETE pragmas, since those two feel very similar to me? So instead of multiple pragmas, let's have {-# COMPLETE (Pat1, Pat2) | (Pat3, Pat4) #}, just like with {-# MINIMAL #-} ? <div><br></div><div>Regards,</div><div>Benno </div></div><br><div class="gmail_quote"><div dir="ltr">Simon Peyton Jones via ghc-devs <<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a>> schrieb am Fr., 13. Jan. 2017 um 16:50 Uhr:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks.<br class="gmail_msg">
<br class="gmail_msg">
|  > * What if there are multiple COMPLETE pragmas e.g.<br class="gmail_msg">
|  >   {-# COMPLETE A, B, C #-}<br class="gmail_msg">
|  >   {-# COMPLETE A, X, Y, Z #-}<br class="gmail_msg">
|  >   Is that ok?  I guess it should be!<br class="gmail_msg">
|  ><br class="gmail_msg">
|  >   Will the pattern-match exhaustiveness check then succeed<br class="gmail_msg">
|  >   if a function uses either set?<br class="gmail_msg">
|  ><br class="gmail_msg">
|  >   What happens if you use a mixture of constructors in a match<br class="gmail_msg">
|  >   (e.g. A, X, C, Z)?  Presumably all bets are off?<br class="gmail_msg">
|<br class="gmail_msg">
|  Yes this is fine. In the case you ask about then as neither COMPLETE pragma<br class="gmail_msg">
|  will match then the "best" one as described in the error messages section<br class="gmail_msg">
|  will be chosen.<br class="gmail_msg">
<br class="gmail_msg">
The wiki spec doesn't say this (presumably under "semantics").  Could it?<br class="gmail_msg">
<br class="gmail_msg">
|  > * Note that COMPLETE pragmas could be a new source of orphan modules<br class="gmail_msg">
|  >      module M where<br class="gmail_msg">
|  >        import N( pattern P, pattern Q )<br class="gmail_msg">
|  >        {-# COMPLETE P, Q #-}<br class="gmail_msg">
|  >   where neither P nor Q is defined in M.  Then every module that is<br class="gmail_msg">
|  >   transitively "above" M would need to read M.hi just in case its<br class="gmail_msg">
|  >   COMPLETE pragmas was relevant.<br class="gmail_msg">
<br class="gmail_msg">
Can you say this in the spec?<br class="gmail_msg">
<br class="gmail_msg">
|  ><br class="gmail_msg">
|  > * Point out in the spec that COMPLETE pragmas are entirely unchecked.<br class="gmail_msg">
|  >   It's up to the programmer to get it right.<br class="gmail_msg">
<br class="gmail_msg">
Can you say this in the spec?  Ah -- it's in "Discussion"... put it under "Semantics".<br class="gmail_msg">
<br class="gmail_msg">
|  ><br class="gmail_msg">
|  > * Typing.  What does it mean for the types to "agree" with each other.<br class="gmail_msg">
|  >   E.g  A :: a -> [(a, Int)]<br class="gmail_msg">
|  >        B :: b -> [(Int, b)]<br class="gmail_msg">
|  >   Is this ok?  Please say explicitly with examples.<br class="gmail_msg">
|<br class="gmail_msg">
|  This would be ok as the type constructor of both result types is [].<br class="gmail_msg">
<br class="gmail_msg">
Can you say this in the spec?<br class="gmail_msg">
<br class="gmail_msg">
|<br class="gmail_msg">
|  > * I didn't really didn't understand the "Error messages" section.<br class="gmail_msg">
|  ><br class="gmail_msg">
|  ><br class="gmail_msg">
|<br class="gmail_msg">
|  I can't really help unless I know what you don't understand.<br class="gmail_msg">
<br class="gmail_msg">
"The pattern match checker checks each set of patterns individually"<br class="gmail_msg">
<br class="gmail_msg">
Given a program, what are the "sets of patterns", precisely?<br class="gmail_msg">
<br class="gmail_msg">
|  The idea is simply that all the different sets of patterns are tried and<br class="gmail_msg">
|  that the results are prioritised by<br class="gmail_msg">
|<br class="gmail_msg">
|  1. Fewest uncovered clauses<br class="gmail_msg">
|  2. Fewest redundant clauses<br class="gmail_msg">
|  3. Fewest inaccessible clauses<br class="gmail_msg">
|  4. Whether the match comes from a COMPLETE pragma or the build in set of<br class="gmail_msg">
|  data constructors for a type constructor.<br class="gmail_msg">
<br class="gmail_msg">
Some examples would be a big help.<br class="gmail_msg">
<br class="gmail_msg">
Simon<br class="gmail_msg">
<br class="gmail_msg">
|<br class="gmail_msg">
|<br class="gmail_msg">
|<br class="gmail_msg">
|  > Simon<br class="gmail_msg">
|  ><br class="gmail_msg">
|  > |  -----Original Message-----<br class="gmail_msg">
|  > |  From: ghc-devs [mailto:<a href="mailto:ghc-devs-bounces@haskell.org" class="gmail_msg" target="_blank">ghc-devs-bounces@haskell.org</a>] On Behalf Of<br class="gmail_msg">
|  > | Matthew  Pickering<br class="gmail_msg">
|  > |  Sent: 22 November 2016 10:43<br class="gmail_msg">
|  > |  To: GHC developers <<a href="mailto:ghc-devs@haskell.org" class="gmail_msg" target="_blank">ghc-devs@haskell.org</a>><br class="gmail_msg">
|  > |  Subject: Exhaustiveness checking for pattern synonyms<br class="gmail_msg">
|  > |<br class="gmail_msg">
|  > |  Hello devs,<br class="gmail_msg">
|  > |<br class="gmail_msg">
|  > |  I have implemented exhaustiveness checking for pattern synonyms.<br class="gmail_msg">
|  > | The idea is  very simple, you specify a set of pattern synonyms (or<br class="gmail_msg">
|  > | data<br class="gmail_msg">
|  > |  constructors) which are regarded as a complete match.<br class="gmail_msg">
|  > |  The pattern match checker then uses this information in order to<br class="gmail_msg">
|  > | check  whether a function covers all possibilities.<br class="gmail_msg">
|  > |<br class="gmail_msg">
|  > |  Specification:<br class="gmail_msg">
|  > |<br class="gmail_msg">
|  > |  <a href="https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms/CompleteSigs" rel="noreferrer" class="gmail_msg" target="_blank">https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms/CompleteSigs</a><br class="gmail_msg">
|  > |<br class="gmail_msg">
|  > |  <a href="https://phabricator.haskell.org/D2669" rel="noreferrer" class="gmail_msg" target="_blank">https://phabricator.haskell.org/D2669</a><br class="gmail_msg">
|  > |  <a href="https://phabricator.haskell.org/D2725" rel="noreferrer" class="gmail_msg" target="_blank">https://phabricator.haskell.org/D2725</a><br class="gmail_msg">
|  > |<br class="gmail_msg">
|  > |  <a href="https://ghc.haskell.org/trac/ghc/ticket/8779" rel="noreferrer" class="gmail_msg" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/8779</a><br class="gmail_msg">
|  > |<br class="gmail_msg">
|  > |  Matt<br class="gmail_msg">
|  > |  _______________________________________________<br class="gmail_msg">
|  > |  ghc-devs mailing list<br class="gmail_msg">
|  > |  <a href="mailto:ghc-devs@haskell.org" class="gmail_msg" target="_blank">ghc-devs@haskell.org</a><br class="gmail_msg">
|  > |<br class="gmail_msg">
|  > | <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail" rel="noreferrer" class="gmail_msg" target="_blank">https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail</a><br class="gmail_msg">
|  > | .haskell<br class="gmail_msg">
|  > |  .org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fghc-<br class="gmail_msg">
|  > |<br class="gmail_msg">
|  > | devs&data=02%7C01%7Csimonpj%<a href="http://40microsoft.com" rel="noreferrer" class="gmail_msg" target="_blank">40microsoft.com</a>%7C155eb2786cb040d8052908<br class="gmail_msg">
|  > | d412c453<br class="gmail_msg">
|  > | b5%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636154081815249356&s<br class="gmail_msg">
|  > | data=MkQ<br class="gmail_msg">
|  > |  FpwJWaTU%2BdEQSYEBjXLt80BrXLkBp9V8twdKB6BI%3D&reserved=0<br class="gmail_msg">
|<br class="gmail_msg">
|  I updated the wiki page quite a bit. Thanks Simon for the comments.<br class="gmail_msg">
|<br class="gmail_msg">
|  Matt<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
ghc-devs mailing list<br class="gmail_msg">
<a href="mailto:ghc-devs@haskell.org" class="gmail_msg" target="_blank">ghc-devs@haskell.org</a><br class="gmail_msg">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" class="gmail_msg" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br class="gmail_msg">
</blockquote></div>