Algebraic Data Type in Swift

updated about 1 year ago; latest suggestion about 1 year ago

This proposal has been withdrawn...

Swift has a powerful type system that we can compose multiple data into one (i.e. structs and enums) and decompose them using getters and pattern matching.

In functional programming, these types are called "product type" and "sum type" in which, as their names suggest, we can simply sum up or multiply types to create a new one. For example, Optional<T> = 1 + T, Result<T, E> = T + E, Result<Optional<T>, E> = 1 + T + E, etc. Believe it or not, we can play math (algebra) in Swift's type system!

In this talk, we will explore the basics of Algebraic Data Type and its related topics, such as "similarity of types", how Void and Never are similar but different, how "currying" actually works, and so on. We will also have a sneak-peek of underlying math called Category Theory.


  • 8b2f2d3e6553c2b4048b93300959895ab76b4154?size=100x100 8b2f2d3e6553c2b4048b93300959895ab76b4154 suggests about 1 year ago

    What should attendees take away from this talk? It's okay for the end result to just be a general sense of "Hmm. That was interesting." But if you want them to use this information to accomplish something, that would be great to know too.

  • 7b66fb5480f4d6501b9f1be17661732bd39115c6?size=100x100 7b66fb5480f4d6501b9f1be17661732bd39115c6 suggests about 1 year ago

    Any mention of Category Theory is always great in my view, but I think this suggestion would be more appealing if it also included some information on how to use the properties of these algebraic data types to model real world problems.

    This article is a pretty good example of applying these structures to real world problems:

  • 419cdb2751e6a13b3e09323b6f44a9611c757a8b?size=100x100 419cdb2751e6a13b3e09323b6f44a9611c757a8b suggests about 1 year ago

    This seems like a very interesting topic! I would love to hear more about this