git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Update README.md
6a0418fPhil Freeman
README.md+30−8
@@ -178,18 +178,40 @@ In the example, Foo is a tagged union type which has two constructors. It's firs
178
178
179Functions in PureScript can have zero or more arguments in general, just like in Javascript.
179Functions in PureScript can have zero or more arguments in general, just like in Javascript.
180
180
181−Functions are introduced by using a backslash followed by a comma separated list of argument names:
181+Functions are introduced by using a backslash followed by a list of argument names:
182
182
183```haskell
183```haskell
184−test1 = \a, b, c -> a + b + c
184+test1 = \a b -> a + b
185```
185```
186
186
187−which would correspond to the Javascript `function test1(a, b, c) { return a + b + c; }`
187+which would correspond to the Javascript
188+
189+```javascript
190+function test1(a) {
191+ return function (b) {
192+ return a + b;
193+ }
194+}
195+```
196+
197+Multiple argument functions can be introduced by wrapping the arguments in parentheses, and separating them with commas:
198+
199+```haskell
200+test1 = \(a, b) -> a + b
201+```
202+
203+which generates
204+
205+```javascript
206+function test1(a, b) {
207+ return a + b;
208+}
209+```
188
210
189A function taking no arguments would look like this:
211A function taking no arguments would look like this:
190
212
191```haskell
213```haskell
192−test2 = \ -> 100
214+test2 = \() -> 100
193```
215```
194
216
195which would correspond to the Javascript `function test2() { return 100; }`
217which would correspond to the Javascript `function test2() { return 100; }`
@@ -205,7 +227,7 @@ A special case is made in the case of functions with one argument. These functio
205
227
206```haskell
228```haskell
207-- has type Number -> Number -> Number -> Number
229-- has type Number -> Number -> Number -> Number
208−addThree = \a -> \b -> \c -> a + b + c
230+addThree = \a b c -> a + b + c
209
231
210-- has type Number -> Number -> Number
232-- has type Number -> Number -> Number
211addThree 1
233addThree 1
@@ -304,7 +326,7 @@ The following types of statement are supported:
304Here is an example of a power function defined using a block:
326Here is an example of a power function defined using a block:
305
327
306```haskell
328```haskell
307−pow = \n, p -> do
329+pow = \n p -> do
308 var m = n
330 var m = n
309 for i <- 0 until p:
331 for i <- 0 until p:
310 m = m * n
332 m = m * n
@@ -560,7 +582,7 @@ In addition to the standard operators, user-defined infix operators can be creat
560E.g. to create a synonym for string concatenation:
582E.g. to create a synonym for string concatenation:
561
583
562```haskell
584```haskell
563−(<>) = \s1 -> \s2 -> s1 ++ s2
585+(<>) = \s1 s2 -> s1 ++ s2
564
586
565greeting = "Hello" <> "World!"
587greeting = "Hello" <> "World!"
566```
588```
@@ -568,7 +590,7 @@ greeting = "Hello" <> "World!"
568Regular functions can be used as operators by enclosing their names in backticks:
590Regular functions can be used as operators by enclosing their names in backticks:
569
591
570```haskell
592```haskell
571−foo = \x -> \y -> x * y + y
593+foo = \x y -> x * y + y
572
594
573test = 10 `foo` 20
595test = 10 `foo` 20
574```
596```