O'Reilly logo

Haskell Cookbook by Yogesh Sajanikar

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

Defining a sum type

The sum types are equivalent to variant (or union in C). However, sum type in Haskell is much more than that. It is also called tagged union. The simplest sum type is Bool, which can take two values True and False. In this recipe, we will define simple sum types and use them in our example.

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