@@ -7,6 +7,7 @@ The type system defines the following types:
9- Tagged Unions
9- Tagged Unions
10- Functions
11- Functions
11- Polymorphic Types
12- Polymorphic Types
12- Constrained Types
13- Constrained Types
@@ -48,6 +49,20 @@ In the example, Foo is a tagged union type which has two constructors. It's firs
49``runFoo`` is an example of pattern matching on a tagged union type to discover its constructor, and the last line shows how to construct values of type ``Foo``.
50``runFoo`` is an example of pattern matching on a tagged union type to discover its constructor, and the last line shows how to construct values of type ``Foo``.
55+Newtypes are like data types introduced with the ``data`` keyword, but are restricted to a single contructor which contains a single arguments. Newtypes are introduced with the ``newtype`` keyword::
57+ newtype Percentage = Percentage Number
59+The representation of a newtype at runtime is the same as the underlying data type. For example, a value of type ``Percentage`` is just a JavaScript number at runtime.
61+Newtypes can be assigned their own type class instances, so for example, ``Percentage`` can be given its own ``Show`` instance::
63+ instance showPercentage :: Show Percentage where
64+ show (Percentage n) = show n ++ "%"