[swift-evolution] [Proposal] Higher Kinded Types (Monads, Functors, etc.)

Greg Titus greg at omnigroup.com
Wed Dec 16 18:41:24 CST 2015


> On Dec 16, 2015, at 4:26 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> On Dec 16, 2015, at 4:04 PM, Matthew Johnson via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> 
>>> With higher-kinded types, one could potentially [*] produce a collection of the same kind as Self but with the element type T. So, mapping a Set produces a Set, mapping an Array produces an Array, etc. 
>> 
>> I think structure preserving map is a great example and one I hope will eventually make it into the standard library someday.  
> 
> How, specifically, would you use it?  To which types would it apply, and how would the change benefit users?

I think Haskell is lovely, and I’ve bookmarked the Causal Commutative Arrows paper to read for later, but I think… not at all?

I think the part that benefits users is the ideas behind functional programming as made explicit in the standard library. For instance, having all the structures be mappable and foldable in appropriate ways. That this may require some extra boilerplate by the people writing the library implementing that structure is too bad, but not a huge loss, because there just aren’t that many structures that we programmers will use, so the libraries to be written are fairly limited.

I don’t think in my day job as a Swift & Obj-C programmer that I’ve ever had the desire to write code that maps and folds AND is generic in kind of structure and type over which it does so. I generally actually do care and am quite specific about whether it’s an Array or a Set, much less something less generic like a B*-Tree or AST.

	- Greg




More information about the swift-evolution mailing list