@@ -62,18 +62,18 @@ data Person = Person
62 ; age :: Number
62 ; age :: Number
65−extern itoa :: Number -> String
65+extern numberToString :: Number -> String
67showPerson :: Person -> String
67showPerson :: Person -> String
68showPerson = \p -> case p of
68showPerson = \p -> case p of
69− Person o -> o.name ++ ", aged " ++ itoa(o.age)
69+ Person o -> o.name ++ ", aged " ++ numberToString(o.age)
72Line by line, this reads as follows:
72Line by line, this reads as follows:
74- `Person` is a data type with one constructor, also called `Person`
74- `Person` is a data type with one constructor, also called `Person`
75 - The `Person` constructor takes an object with two properties, `name` which is a `String`, and `age` which is a `Number`
75 - The `Person` constructor takes an object with two properties, `name` which is a `String`, and `age` which is a `Number`
76−- The `itoa` function is written in Javascript, and takes a `Number` and returns a `String`
76+- The `numberToString` function is written in Javascript, and converts a `Number` to its `String` representation
77- The `showPerson` function takes a `Person` and returns a `String`
77- The `showPerson` function takes a `Person` and returns a `String`
78- `showPerson` works by case analysis on its argument `p`, first matching the constructor `Person` and then using string concatenation and object accessors to return its result.
78- `showPerson` works by case analysis on its argument `p`, first matching the constructor `Person` and then using string concatenation and object accessors to return its result.
@@ -84,12 +84,12 @@ var Person = function (value) {
84 return { ctor: 'Person', value: value };
84 return { ctor: 'Person', value: value };
87−var showPerson = function (p) {
87+function showPerson(p) {
88 return (function (_0) {
88 return (function (_0) {
89 if (_0.ctor === "Person") {
89 if (_0.ctor === "Person") {
90 var _1 = _0.value;
90 var _1 = _0.value;
91 var o = _1;
91 var o = _1;
92− return o.name ++ ", aged " ++ itoa(o.age);
92+ return o.name ++ ", aged " ++ numberToString(o.age);
94 throw "Failed pattern match";
94 throw "Failed pattern match";