@@ -15,7 +15,6 @@ But this is not::
16 foo = bar(x) +
16 foo = bar(x) +
@@ -61,7 +60,7 @@ and the following binary operators (in precedence order):
61Literal Values
60Literal Values
62--------------
61--------------
64−Numeric literals can be integers or floating point numbers. Numbers in hexadecimal notation should be preceded by the characters `0x`::
63+Numeric literals can be integers or floating point numbers. Numbers in hexadecimal notation should be preceded by the characters ``0x``::
@@ -123,53 +122,14 @@ which would correspond to the following Javascript::
126−Multiple argument functions can be introduced by wrapping the arguments in parentheses, and separating them with commas::
125+Function application is indicated by just the juxtaposition of a function with its arugments::
128− example2 = \(a, b) -> a + b
127+ example1 10 20
130−which generates::
129+Functions can also be defined at the top level by providing a list of patterns and an optional guard on the left hand side of the equals sign::
132− function example2(a, b) {
131+ f [] [] = []
133− return a + b;
132+ f (x:xs) (y:ys) = x + y : f xs ys
136−There is a special case for functions with no arguments, where the parentheses may be omitted, as follows::
140−which would correspond to the Javascript::
142− function example3() {
146−Multiple-argument and single-argument syntax can be mixed, as follows::
148− example4 = \a (b, c) d -> a + b + c + d
152− function example4(a) {
153− return function (b, c) {
154− return function (d) {
155− return a + b + c + d;
160−Functions are applied by providing their arguments inside parentheses::
165−A special case is made in the case of functions with one argument. These functions can be applied without parentheses, and function application associates to the left::
167− addThree :: Number -> Number -> Number -> Number
168− addThree a b c = a + b + c
170− addThree 1 :: Number -> Number -> Number
171− addThree 1 2 :: Number -> Number
172− addThree 1 2 3 :: Number
174If-Then-Else Expressions
134If-Then-Else Expressions
175------------------------
135------------------------
@@ -204,23 +164,23 @@ Here is an example, using the maybe monad::
204 isEven sum
164 isEven sum
207−`isEven` adds two values of type `Maybe Number` and returns their sum, if the sum is even. If the sum is odd, `evenSum` returns `Nothing`.
167+``isEven`` adds two values of type ``Maybe Number`` and returns their sum, if the sum is even. If the sum is odd, ``evenSum`` returns ``Nothing``.
209−When using `do` notation, the corresponding type constructor must be an instance of the `Prelude.Monad` type class, which defines the `ret` and `>>=` functions.
169+When using `do` notation, the corresponding type constructor must be an instance of the `Prelude.Monad` type class, which defines the ``ret`` and ``>>=`` functions.
211Statements can have the following form:
171Statements can have the following form:
213−- `a <- x` which desugars to `m.bind x (\a -> ...)`
173+- ``a <- x`` which desugars to ``m.bind x (\a -> ...)` `
214−- `let a = x` which desugars to `(\a -> ...)(x)`
174+- ``let a = x`` which desugars to ``(\a -> ...)(x)``
215−- `x` which desugars to `m.bind x (\_ -> ...)` or just `x` if this is the last statement.
175+- ``x`` which desugars to ``m.bind x (\_ -> ...)`` or just ``x`` if this is the last statement.
217−Binders can be used on the left hand side of `<-` or `=`. For example::
177+Binders can be used on the left hand side of ``<-`` or ``=``. For example::
219 test arr = do
179 test arr = do
220 (x:y:_) <- arr
180 (x:y:_) <- arr
221 ret (x + y)
181 ret (x + y)
223−A pattern match failure will generate a runtime exception, just as in the case of a regular `case` statement.
183+A pattern match failure will generate a runtime exception, just as in the case of a regular ``case`` statement.
@@ -251,11 +211,11 @@ Properties on records can be updated using the following syntax::
252 o { key = value, ..., key = value }
212 o { key = value, ..., key = value }
254−For example, the following function increments the `foo` property on its argument::
214+For example, the following function increments the ``foo`` property on its argument::
256− incr = \o -> o { foo = o.foo + 1 }
216+ incr o = o { foo = o.foo + 1 }
258−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::
218+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::
260 Object.prototype.extend = function(o, p) {
220 Object.prototype.extend = function(o, p) {
261 return $.extend({}, o, p);
221 return $.extend({}, o, p);