O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Kinds of types

You may have heard that Functional Programming (FP) uses concepts of the category theory and type theory. This link is the reason why some people find FP closer to mathematics. Theoretically, category refers to a collection that contains the following:

  • A collection of objects (types in Swift)
  • A collection of morphisms, each of which ties two objects together (functions in Swift)
  • A notion of composition of the morphisms (function composition in Swift)

We have already discussed functions and function composition and now we are going to explore types.

It is possible to categorize types in four different ways:

  • Named versus compound types
  • Sum versus product types
  • Abstract versus concrete types
  • Value versus reference types

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required