<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">I propose that it should be possible to declare type-inferred properties that derive from the required properties of a class or struct.</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">struct</span><span style="font-variant-ligatures: no-common-ligatures" class=""> SignedSequences<S: SequenceType </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">where</span><span style="font-variant-ligatures: no-common-ligatures" class=""> S.Generator.Element : SignedIntegerType> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> seq: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">S</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> absoluteEvens: </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.seq.lazy.filter({ x </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> x % 2 == 0 }).map({ x </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> abs(x) })</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> positiveOdds: </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.seq.lazy.filter({ x </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> x > 0 }).filter({ x </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> x % 2 == 1 })</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> brutePrimes: </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.positiveOdds.lazy.filter({ $0 >= 2 }).filter({ s </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (2..<s).filter({ x </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> s % x == 0 }).isEmpty })</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">init</span><span style="font-variant-ligatures: no-common-ligatures" class="">(sequence: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">S</span><span style="font-variant-ligatures: no-common-ligatures" class="">) {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">seq</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = sequence</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class="">Currently, to accomplish this, you need to explicitly declare the types for each of the derived properties, which can be tedious, and which requires the separation of the declaration from the invariant logic.</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">struct</span><span style="font-variant-ligatures: no-common-ligatures" class=""> SignedSequences<S: SequenceType </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">where</span><span style="font-variant-ligatures: no-common-ligatures" class=""> S.Generator.Element : SignedIntegerType> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> seq: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">S</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> absoluteEvens: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">LazyMapSequence</span><span style="font-variant-ligatures: no-common-ligatures" class=""><</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">LazyFilterSequence</span><span style="font-variant-ligatures: no-common-ligatures" class=""><</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">S</span><span style="font-variant-ligatures: no-common-ligatures" class="">>, </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">S</span><span style="font-variant-ligatures: no-common-ligatures" class="">.Generator.Element></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(52, 149, 175);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">let</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> positiveOdds: </span><span style="font-variant-ligatures: no-common-ligatures" class="">LazyFilterSequence</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><</span><span style="font-variant-ligatures: no-common-ligatures" class="">LazyFilterSequence</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><</span><span style="font-variant-ligatures: no-common-ligatures" class="">S</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">>></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(52, 149, 175);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">let</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> brutePrimes: </span><span style="font-variant-ligatures: no-common-ligatures" class="">LazyFilterSequence</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><</span><span style="font-variant-ligatures: no-common-ligatures" class="">LazyFilterSequence</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><</span><span style="font-variant-ligatures: no-common-ligatures" class="">LazyFilterSequence</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><</span><span style="font-variant-ligatures: no-common-ligatures" class="">LazyFilterSequence</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><</span><span style="font-variant-ligatures: no-common-ligatures" class="">S</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">>>>></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">init</span><span style="font-variant-ligatures: no-common-ligatures" class="">(sequence: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">S</span><span style="font-variant-ligatures: no-common-ligatures" class="">) {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">seq</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = sequence</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">absoluteEvens</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">seq</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">lazy</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">filter</span><span style="font-variant-ligatures: no-common-ligatures" class="">({ x </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> x </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">%</span><span style="font-variant-ligatures: no-common-ligatures" class=""> 2 </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">==</span><span style="font-variant-ligatures: no-common-ligatures" class=""> 0 }).</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">map</span><span style="font-variant-ligatures: no-common-ligatures" class="">({ x </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">abs</span><span style="font-variant-ligatures: no-common-ligatures" class="">(x) })</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">positiveOdds</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">seq</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">lazy</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">filter</span><span style="font-variant-ligatures: no-common-ligatures" class="">({ x </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> x </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">></span><span style="font-variant-ligatures: no-common-ligatures" class=""> 0 }).</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">filter</span><span style="font-variant-ligatures: no-common-ligatures" class="">({ x </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> x </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">%</span><span style="font-variant-ligatures: no-common-ligatures" class=""> 2 </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">==</span><span style="font-variant-ligatures: no-common-ligatures" class=""> 1 })</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">brutePrimes</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">positiveOdds</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">lazy</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">filter</span><span style="font-variant-ligatures: no-common-ligatures" class="">({ $0 </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">>=</span><span style="font-variant-ligatures: no-common-ligatures" class=""> 2 }).</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">filter</span><span style="font-variant-ligatures: no-common-ligatures" class="">({ s </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (2..<s).</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">filter</span><span style="font-variant-ligatures: no-common-ligatures" class="">({ x </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> s </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">%</span><span style="font-variant-ligatures: no-common-ligatures" class=""> x </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">==</span><span style="font-variant-ligatures: no-common-ligatures" class=""> 0 }).</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">isEmpty</span><span style="font-variant-ligatures: no-common-ligatures" class=""> })</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">This would just be a compiler enhancement, since the generated SIL would be identical in the two examples.</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class="">What do people think?<br class=""><br class=""><br class=""></div></body></html>