A sum type combines many possible differently-typed values into a single value, expressed in Swift as an…