<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 20, 2016, at 02:26, Tim Vermeulen &lt;<a href="mailto:tvermeulen@me.com" class="">tvermeulen@me.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">What you’re saying makes sense, and I might not have brought this up in the first place if `first.map { sequence(first: $0, next: next } ?? []` worked. The main annoyance is that the best solution (currently) seems to be to copy the source code and make a change.</div><div class=""><br class=""></div><div class="">(cc-ing Jordan Rose because of a related swift-users thread) This might be a bit of a stretch, but can’t Swift upcast sequences to AnySequence implicitly, like is done with AnyHashable? That would make `first.map { sequence(first: $0, next: next } ?? []` instantly valid, I think. There’s also something to be said for consistency between type erasers. (I’m not necessarily talking about Swift 3)</div></div></div></blockquote></div><br class=""><div class="">Sorry to let this sit. I really would not want to implement this by upcasting to AnySequence. That would be tremendously inefficient.</div><div class=""><br class=""></div><div class="">In general, AnyHashable is special because of dictionary literals, where the same thing would have to be specified over and over again. That’s not true here. (And we weren’t even going to do it for AnyHashable originally.)</div><div class=""><br class=""></div><div class="">I’m mildly in favor of the very original form of this proposal,</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">func sequence(first: T?, next: @escaping (T) -&gt; T?) -&gt;&nbsp;UnfoldFirstSequence&lt;T&gt;</div></blockquote><div class=""><br class=""></div><div class="">It’s also very nearly an additive change; the only existing code that would change meaning is that IUOs would not cause traps. (And the contrived examples with almost no type information, where the user is <i class="">currently</i>&nbsp;trying to infer T = Optional&lt;X&gt; and return a sequence of Optional&lt;X&gt;.)</div><br class=""><div class="">Jordan</div></body></html>