Algebraic Data Type in Swift
updated over 1 year ago; latest suggestion over 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 sneakpeek of underlying math called Category Theory.
Suggestions

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.

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: https://medium.com/@mttkay/refactoringwithmonoidsandsumtypespart1bddc9ea61f5f

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