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

Matthew Johnson matthew at anandabits.com
Wed Dec 16 18:04:08 CST 2015


> 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.  I would really like to see HKTs in Swift but I agree that they are a much lower priority for day-to-day development than filling out the holes in the existing generics features.  

That is especially true for the majority of Swift developers who haven’t spent a lot of time studying functional programming, Haskell, reading academic papers, etc.  This stuff takes significant time and thought investment to understand and become fluent in.  Most developers will not devote the time to do that without a compelling reason.  Doug’s request for concrete examples applicable to the average Swift developer is very reasonable.

Will, if you have ideas for libraries you would like to write that would require HKTs to implement (beyond just saving some boilerplate in the implementation), are tractable to an average Swift developer (for some reasonable definition of average), and provide compelling advantages over alternatives please do share them!  I’m sure I would learn something useful and you might be able to make some headway towards motivating a higher priority for HKTs.

Matthew


More information about the swift-evolution mailing list