<p dir="ltr">There are two features I think would make pattern synonyms even nicer:</p>
<p dir="ltr">1. If a pattern synonym is defined in the same module as one of the type constructors in the type of thing it matches, then it should be possible to export it "attached" to one or more of those constructors (normally but not necessarily the outermost one g. An example of how this might look:</p>
<p dir="ltr">module Foo (A (.., S))<br>
data A = X | Y<br>
pattern S = X</p>
<p dir="ltr">Someone writing a module importing Foo wouldn't even need to know that S was a pattern synonym--they'd just</p>
<p dir="ltr">import Foo (A (..))</p>
<p dir="ltr">and be done with it. The (.., S) here means "export all A's constructors, along with the pattern synonym S".</p>
<p dir="ltr">2. Pattern synonym groups</p>
<p dir="ltr">This vague idea attacks a long-standing efficiency concern. It's not fully formed in my mind, but I'd love to be able to write groups of pattern synonyms that all use a *guaranteed shared* computed view of the underlying structure. Once the first synonym in the group is encountered, the view is calculated and held until the pattern match completes or the last synonym in the group is rejected.</p>