next up previous
Next: Enumerated Types Up: The Frightened Freshers Guide Previous: Conditional statements (If-then-else)

Types in Haskell

Although we have seen a few datatypes so far (Int and Boolean) there are a number of other types! Heres a nice table to show you some of the types that can be used.

 Type Description
 Int Stores whole numbers
 Float Stores decimals
 Bool Stores True or False
 Char Stores single characters
 String Stores lots of chars

Note that all the datatypes start with a capital letter. We can define as many new types as we like, for example we may want to define a new datatype that contains the Months of the year, days in a week or abstract things like a directory of names and passwords, filesystem layout and so on. There are two type definitions, Enumerated types and alternatives. Bool is an example of an enumerated type as it has two elements which are True and False. Alternatives could contain other types. For example, if we had two types defined called Circle and Square then a Shapes datatype could have Circle or Square contained inside of it.


next up previous
Next: Enumerated Types Up: The Frightened Freshers Guide Previous: Conditional statements (If-then-else)
Tom Carlson 2006-04-11