git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #259 from timmytofu/patch-2
62b500aPhil Freeman
docs/source/intro.rst+11
@@ -102,6 +102,10 @@ The following code defines a `Person` data type and a function to generate a str
102
102
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)
105+
106+ examplePerson :: Person
107+ examplePerson = Person {name: "Bonnie", age: 26}
108+
105
109
106Line by line, this reads as follows:
110Line by line, this reads as follows:
107
111
@@ -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.
113
118
114The generated Javascript looks like this::
119The generated Javascript looks like this::
115
120
@@ -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);
122 };
127 };
128+
129+ var examplePerson = Person({
130+ name: "Bonnie",
131+ age: 26
132+ });
133+
123
134
124Related Projects
135Related Projects
125----------------
136----------------