O'Reilly logo

Get Programming with Haskell by Will Kurt

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

Lesson 12. Creating your own types

After reading lesson 12, you’ll be able to

  • Define type synonyms to clarify code
  • Create your own data type
  • Build types from other types
  • Work with complex types by using record syntax

In the preceding lesson, you learned how to use the basic types in Haskell. Now it’s time to start creating some types of your own. Creating types in Haskell is more important than in most other programming languages, even statically typed ones, as nearly every problem you solve will come down to the types you’re using. Even when using an existing type, you’ll often want to rename it to make understanding your programs easier. For example, take a look at this type signature:

areaOfCircle :: Double -> Double

This is a perfectly ...

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