@@ -102,6 +102,10 @@ The following code defines a `Person` data type and a function to generate a str
103 showPerson :: Person -> String
103 showPerson :: Person -> String
104 showPerson (Person o) = o.name ++ ", aged " ++ numberToString(o.age)
104 showPerson (Person o) = o.name ++ ", aged " ++ numberToString(o.age)
106+ examplePerson :: Person
107+ examplePerson = Person {name: "Bonnie", age: 26}
106Line by line, this reads as follows:
110Line by line, this reads as follows:
@@ -110,6 +114,7 @@ Line by line, this reads as follows:
110- The `numberToString` function is written in Javascript, and converts a `Number` to its `String` representation
114- The `numberToString` function is written in Javascript, and converts a `Number` to its `String` representation
111- The `showPerson` function takes a `Person` and returns a `String`
115- The `showPerson` function takes a `Person` and returns a `String`
112- `showPerson` works by case analysis on its argument, first matching the constructor `Person` and then using string concatenation and object accessors to return its result.
116- `showPerson` works by case analysis on its argument, first matching the constructor `Person` and then using string concatenation and object accessors to return its result.
117+- `examplePerson` is a Person object, made with the Person constructor and given the String "Bonnie" for the name value and the Number 26 for the age value.
114The generated Javascript looks like this::
119The generated Javascript looks like this::
@@ -120,6 +125,12 @@ The generated Javascript looks like this::
120 function showPerson(_1) {
125 function showPerson(_1) {
121 return _1.values[0].name + ", aged " + numberToString(_1.values[0].age);
126 return _1.values[0].name + ", aged " + numberToString(_1.values[0].age);
129+ var examplePerson = Person({
124Related Projects
135Related Projects
125----------------
136----------------