git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge branch 'master' of github.com:paf31/purescript
f98236ePhil Freeman
README.md+5−5
@@ -62,18 +62,18 @@ data Person = Person
62 ; age :: Number
62 ; age :: Number
63 }
63 }
64
64
65−extern itoa :: Number -> String
65+extern numberToString :: Number -> String
66
66
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)
70```
70```
71
71
72Line by line, this reads as follows:
72Line by line, this reads as follows:
73
73
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.
79
79
@@ -84,12 +84,12 @@ var Person = function (value) {
84 return { ctor: 'Person', value: value };
84 return { ctor: 'Person', value: value };
85};
85};
86
86
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);
93 }
93 }
94 throw "Failed pattern match";
94 throw "Failed pattern match";
95 })(p);
95 })(p);