git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Update syntax.rst
bd2173dPhil Freeman
docs/source/syntax.rst+18
@@ -211,3 +211,21 @@ Fixity declarations can associate a precedence level, which is a natural number,
211infixl 5 <>
211infixl 5 <>
212infixr 7 %%
212infixr 7 %%
213```
213```
214+
215+## Record Updates
216+
217+Properties on records can be updated using the following syntax: `o { key = value, ..., key = value }`
218+
219+For example, the following function increments the `foo` property on its argument:
220+
221+```haskell
222+incr = \o -> o { foo = o.foo + 1 }
223+```
224+
225+The generated Javascript assumes the existence of a method called `Object.extend` such that `Object.extend(o, p)` takes an object `o` and generates a shallow copy of `o` including the properties of `p`. A simple JQuery implementation of this specification is
226+
227+```haskell
228+Object.prototype.extend = function(o, p) {
229+ return $.extend({}, o, p);
230+};
231+```