<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body><div>3. Someone could write</div><div><br></div><div>pattern P x <- ... where</div><div>  P :: ...</div><div>  P x = ...</div><div><br></div><div>The pattern signature has to be the same as the constructor signature except for constraints, so it doesn't necessarily sound trivial to infer.</div><div><br></div><div><br></div><div><br></div><div id="composer_signature"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><div style="font-size:85%;color:#575757">David Feuer</div><div style="font-size:85%;color:#575757">Well-Typed, LLP</div></div><div><br></div><div style="font-size:100%;color:#000000"><!-- originalMessage --><div>-------- Original message --------</div><div>From: Simon Peyton Jones <simonpj@microsoft.com> </div><div>Date: 1/15/18  6:36 PM  (GMT-05:00) </div><div>To: David Feuer <david@well-typed.com> </div><div>Cc: ghc-devs@haskell.org </div><div>Subject: RE: Implementing pattern synonym constructor signatures </div><div><br></div></div>0. Parsing. I wasn't actually able to find the code that parses pattern synonyms. Can someone point me in the right direction?<br><br>Parser.y line 1356, production ‘patteron_synonym_decl’ looks plausible.<br><br>Currently we have<br>data HsPatSynDir id<br>  = Unidirectional<br>  | ImplicitBidirectional<br>  | ExplicitBidirectional (MatchGroup id (LHsExpr id))<br>so in the bidirectional case all we have a MatchGroup, built with mkPatSynMatchGroup.    To serve the proposal we need an optional signature in there too.<br><br>1. When there is a constructor signature, it needs to be used for the construction function instead of the pattern signature. Can someone give point me in the right direction about how to do this?<br><br>TcPatSyn.tcPatSynBuilderBind is a good place to start.<br><br>2. When there is a constructor signature but no pattern signature, what should we do? I think "give up" sounds okay for now.<br><br>I don’t understand.  Can you give an example?<br><br>Simon<br>From: David Feuer [mailto:david@well-typed.com]<br>Sent: 15 January 2018 19:11<br>To: Simon Peyton Jones <simonpj@microsoft.com><br>Cc: ghc-devs@haskell.org<br>Subject: Implementing pattern synonym constructor signatures<br><br>Over the past week I've started digging into the code that implements pattern synonyms with an eye toward implementing the pattern synonym construction function signature proposal. I think I understand a decent amount of what's going on most places. However, I don't understand enough about type checking to have any idea about what needs to change where or how. There are several things that need to be addressed:<br><br>0. Parsing. I wasn't actually able to find the code that parses pattern synonyms. Can someone point me in the right direction?<br><br>1. When there is a constructor signature, it needs to be used for the construction function instead of the pattern signature. Can someone give point me in the right direction about how to do this?<br><br>2. When there is a constructor signature but no pattern signature, what should we do? I think "give up" sounds okay for now.<br><br>3. A pattern synonym without a constructor signature needs to be treated as it is today, so the machinery for matching things up needs to remain available.<br><br>David Feuer<br>Well-Typed, LLP<br></body></html>