@@ -1,5 +1,5 @@
1−purescript
1+Introduction
2−==========
2+============
4PureScript is a small strongly, statically typed compile-to-JS language with a number of interesting features, such as:
4PureScript is a small strongly, statically typed compile-to-JS language with a number of interesting features, such as:
@@ -18,45 +18,34 @@ PureScript is a small strongly, statically typed compile-to-JS language with a n
18- Optional tail-call elimination
18- Optional tail-call elimination
19- Type Classes
19- Type Classes
23Try PureScript in the browser [here](http://tryps.functorial.com/).
24Try PureScript in the browser [here](http://tryps.functorial.com/).
25−## Installation
26+Installation
27Install the Haskell Plaform, then `cabal install`
29Install the Haskell Plaform, then `cabal install`
31The `psc` executable takes a list of PureScript source files as arguments and by default writes out its errors or output to the console.
34The `psc` executable takes a list of PureScript source files as arguments and by default writes out its errors or output to the console.
33The following options are supported:
36The following options are supported:
36− Read input from standard input instead of from files
38+-s --stdin Read input from standard input instead of from files
39− Write the generated Javascript to the specified file
39+-o --output Write the generated Javascript to the specified file
42− Write a list of foreign imports declarations to the specified file in addition to generating Javascript output
40+-e --foreign imports Write a list of foreign imports declarations to the specified file in addition to generating Javascript output
44− --runtime-type-checks
45− Generate simple runtime type checks for function arguments with simple types.
41+--runtime-type-checks Generate simple runtime type checks for function arguments with simple types.
48− Perform tail-call elimination on the generated Javascript.
42+--tco Perform tail-call elimination on the generated Javascript.
51− Do not include the Prelude in the generated Javascript.
43+--no-prelude Do not include the Prelude in the generated Javascript.
54− Overload the `do` keyword to inline calls to `bind` for the `Eff` monad, to generate more efficient code.
44+--magic-do Overload the `do` keyword to inline calls to `bind` for the `Eff` monad, to generate more efficient code.
57− Generate a call to `Main.main` after all other generated Javascript.
45+--run-main Generate a call to `Main.main` after all other generated Javascript.
59−## Motivation
47+Motivation
61I was looking for a simple functional language which would compile to JavaScript and have the following characteristics:
50I was looking for a simple functional language which would compile to JavaScript and have the following characteristics:
@@ -72,46 +61,40 @@ PureScript is *not* designed to be a general-purpose programming language. The p
73PureScript can also be seen as a trade-off between a theoretically ideal language and one which generates reasonably high performance code.
62PureScript can also be seen as a trade-off between a theoretically ideal language and one which generates reasonably high performance code.
75−## Hello, PureScript!
64+Hello, PureScript!
77−As an introductory example, here is the usual "Hello World" written in PureScript:
84−main = trace "Hello, World!"
67+As an introductory example, here is the usual "Hello World" written in PureScript::
87−which compiles to the following Javascript, ignoring the Prelude:
69+ module Main where
73+ main = trace "Hello, World!"
89−```javascript
75+which compiles to the following Javascript, ignoring the Prelude::
92− var main = trace("Hello, World!");
94−})(Main = Main || {});
97−The following command will compile and execute the PureScript code above:
77+ var Main;
79+ var main = trace("Hello, World!");
81+ })(Main = Main || {});
99−```
83+The following command will compile and execute the PureScript code above::
100−psc input.purs --run-main | nodejs
103−## Another Example
85+ psc input.purs --run-main | nodejs
105−The following code defines a `Person` data type and a function to generate a string representation for a `Person`:
87+Another Example
107−```haskell
90+The following code defines a `Person` data type and a function to generate a string representation for a `Person`::
108−data Person = Person { name :: String, age :: Number }
92+ data Person = Person { name :: String, age :: Number }
110−foreign import numberToString :: Number -> String
94+ foreign import numberToString :: Number -> String
112−showPerson :: Person -> String
96+ showPerson :: Person -> String
113−showPerson (Person o) = o.name ++ ", aged " ++ numberToString(o.age)
97+ showPerson (Person o) = o.name ++ ", aged " ++ numberToString(o.age)
116Line by line, this reads as follows:
99Line by line, this reads as follows:
@@ -121,18 +104,12 @@ Line by line, this reads as follows:
121- The `showPerson` function takes a `Person` and returns a `String`
104- The `showPerson` function takes a `Person` and returns a `String`
122- `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.
105- `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.
124−The generated Javascript looks like this:
107+The generated Javascript looks like this::
127−var Person = function (value) {
128− return { ctor: 'Person', value: value };
131−function showPerson(_1) {
132− if (_1.ctor === "Person") {
133− return _1.value.name + ", aged " + numberToString(_1.value.age);
135− throw "Failed pattern match";
138−```
109+ var Person = function (value) {
110+ return { ctor: 'Person', value: value };
113+ function showPerson(_1) {
114+ return _1.value.name + ", aged " + numberToString(_1.value.age);