<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="">Questions being raised in this discussion:</div><div class=""><br class=""></div><div class="">* Are the current stdlib names for optional <font face="Courier" class="">map</font> and <font face="Courier" class="">flatMap</font> misleading? </div><div class="">* Are the current stdlib functions for optional closure application appropriate and sufficient?</div><div class=""><br class=""></div><div class=""><div class=""><font face="Courier" class=""> @warn_unused_result</font></div><div class=""><font face="Courier" class=""> public func map<U>(@noescape f: (Wrapped) throws -> U) rethrows -> U?</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class=""> @warn_unused_result</font></div><div class=""><font face="Courier" class=""> public func flatMap<U>(@noescape f: (Wrapped) throws -> U?) rethrows -> U?</font></div></div><div class=""><br class=""></div><div class="">Assume there could be up to three stdlib functions just for applying closures to .some-case </div><div class="">optionals. Would they look like this?</div><div class=""><br class=""></div><div class=""><font face="Courier" class="">public func f1<U>(@noescape f: (Wrapped) throws -> U) rethrows -> U?</font></div><div class=""><div class=""><font face="Courier" class="">public func f2<U>(@noescape f: (Wrapped) throws -> U!) rethrows -> U!</font></div></div><div class=""><div class=""><font face="Courier" class="">public func f3<U>(@noescape f: (Wrapped) throws -> U) rethrows -> Void</font></div></div><div class=""><br class=""></div><div class="">Right now f2/flatMap returns U?, not U or U!, and won't throw if nil, right? Should it</div><div class="">stay that way or change to something that throws and returns a guaranteed value?</div><div class="">Or maybe the current "f2" model (flatMap) be discarded and replaced by an </div><div class="">"<font face="Courier" class="">ifPresent</font>"-like Void call?</div><div class=""><br class=""></div><div class="">And regardless of which functions are included, what would the appropriate </div><div class="">names for each function style be?</div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On Mar 20, 2016, at 11:22 AM, Andrey Tarantsov <<a href="mailto:andrey@tarantsov.com" class="">andrey@tarantsov.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><blockquote type="cite" class="">No. My argument is that map on collections and on optionals are two<br class="">completely different things. They unify on a level that does not<br class="">exist in Swift (higher-kinded types).<br class=""></blockquote><br class="">+1000.<br class=""><br class="">Optional.map is already highly unfortunate. It makes optional arrays especially painful to deal with, but even in general, you can no longer glance at the code and see which parts are dealing with many items and which parts are dealing with single items.<br class=""><br class="">I would definitely support renaming Optional.{map,flatMap}.<br class=""><br class="">A.<br class=""><br class=""></div></div></blockquote></div><br class=""></div></body></html>