diff --git a/part1.html b/part1.html index ac48ce6..f0f03d3 100644 --- a/part1.html +++ b/part1.html @@ -3216,7 +3216,7 @@ It turns a list of pairs into a list of elements
This gives you accessor functions like field1 :: TypeName -> Field1Type for free.
In addition to the data keyword, there are two additional ways of defining types in Haskell.
The newtype keyword works like data, but you can only have a single constructor with a single field. It’s sometimes wise to use newtype for performance resons, but we’ll get back to those in part 2.
The newtype keyword works like data, but you can only have a single constructor with a single field. It’s sometimes wise to use newtype for performance reasons, but we’ll get back to those in part 2.
The type keyword introduces a type alias. Type aliases don’t affect type checking, they just offer a shorthand for writing types. For example the familiar String type is an alias for [Char]:
type String = [Char]This means that whenever the compiler reads String, it just immediately replaces it with [Char]. Type aliases seem useful, but they can easily make reading type errors harder.