O'Reilly logo

Programming in Haskell by Graham Hutton

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

chapter 10

Declaring types and classes

In this chapter we introduce mechanisms for declaring new types and classes in Haskell. We start with two approaches to declaring types, then consider recursive types, develop a tautology checker and an abstract machine, and conclude by showing how to declare classes and their instances.

10.1 Type declarations

The simplest way of declaring a new type is to introduce a new name for an existing type, using the type mechanism of Haskell. For example, the following declaration from the standard library states that the type String is just a synonym for the type [Char] of lists of characters:

As in this 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