A new Swift video series exploring functional programming and more.
#36 • Monday Nov 5, 2018 • Subscriber-only

Advanced Protocol Witnesses: Part 2

We complete our dictionary for translating Swift protocol concepts into concrete datatypes and functions. This includes protocol inheritance, protocol extensions, default implementations and protocols with associated types. Along the way we will also show how concrete types can express things that are currently impossible with Swift protocols.

#36 • Monday Nov 5, 2018 • Subscriber-only

Advanced Protocol Witnesses: Part 2

We complete our dictionary for translating Swift protocol concepts into concrete datatypes and functions. This includes protocol inheritance, protocol extensions, default implementations and protocols with associated types. Along the way we will also show how concrete types can express things that are currently impossible with Swift protocols.


Subscribe to Point‑Free

This episode is for subscribers only. To access it, and all past and future episodes, become a subscriber today!

See subscription optionsorLog in

Sign up for our weekly newsletter to be notified of new episodes, and unlock access to any subscriber-only episode of your choosing!

Sign up for free episode


References

  • Protocol Oriented Programming is Not a Silver Bullet

    Chris Eidhof • Thursday Nov 24, 2016

    An old article detailing many of the pitfalls of Swift protocols, and how often you can simplify your code by just using concrete datatypes and values. Chris walks the reader through an example of some networking API library code, and shows how abstracting the library with protocols does not give us any tangible benefits, but does increase the complexity of the code.

  • Value-Oriented Programming

    Matt Diephouse • Sunday Jul 29, 2018

    Matt gives another account of protocol-oriented programming gone awry, this time by breaking down the famous WWDC talk where a shape library is designed using protocols. By rewriting the library without protocols Matt ends up with something that can be tested without mocks, can be inspected at runtime, and is more flexible in general.

  • Scrap your type classes

    Gabriel Gonzalez • Wednesday May 2, 2012

    Haskell’s notion of protocols are called “type classes,” and the designers of Swift have often stated that Swift’s protocols took a lot of inspiration from Haskell. This means that Haskellers run into a lot of the same problems we do when writing abstractions with type classes. In this article Gabriel Gonzalez lays down the case for scrapping type classes and just using simple datatypes.

  • Some news about contramap

    Brandon Williams • Monday Oct 29, 2018

    A few months after releasing our episode on Contravariance we decided to rename this fundamental operation. The new name is more friendly, has a long history in mathematics, and provides some nice intuitions when dealing with such a counterintuitive idea.

  • Contravariance

    Julie Moronuki & Chris Martin

    This article describes the ideas of contravariance using the Haskell language. In many ways exploring functional programming concepts in Haskell is “easier” because the syntax is sparse and allows you to focus on just the core ideas.

Chapters
Introduction
00:05
Tuple witnesses
01:17
Function witnesses
06:16
Protocol inheritance
11:17
Protocol extensions
17:11
Associated types
24:55
What’s the point?
34:08
Credits

Hosted by Brandon Williams and Stephen Celis. Recorded in Brooklyn, NY.