@@ -1,5 +1,5 @@
1−purescript
2−==========
1+Introduction
2+============
33
44PureScript is a small strongly, statically typed compile-to-JS language with a number of interesting features, such as:
55
@@ -18,45 +18,34 @@ PureScript is a small strongly, statically typed compile-to-JS language with a n
1818- Optional tail-call elimination
1919- Type Classes
2020
21−## Try It!
21+Try It!
22+-------
2223
2324Try PureScript in the browser [here](http://tryps.functorial.com/).
2425
25−## Installation
26+Installation
27+------------
2628
2729Install the Haskell Plaform, then `cabal install`
2830
29−## Usage
31+Usage
32+-----
3033
3134The `psc` executable takes a list of PureScript source files as arguments and by default writes out its errors or output to the console.
3235
3336The following options are supported:
3437
35− -s --stdin
36− Read input from standard input instead of from files
37−
38− -o --output
39− Write the generated Javascript to the specified file
40−
41− -e --foreign imports
42− Write a list of foreign imports declarations to the specified file in addition to generating Javascript output
43−
44− --runtime-type-checks
45− Generate simple runtime type checks for function arguments with simple types.
46−
47− --tco
48− Perform tail-call elimination on the generated Javascript.
49−
50− --no-prelude
51− Do not include the Prelude in the generated Javascript.
52−
53− --magic-do
54− Overload the `do` keyword to inline calls to `bind` for the `Eff` monad, to generate more efficient code.
55−
56− --run-main
57− Generate a call to `Main.main` after all other generated Javascript.
58−
59−## Motivation
38+-s --stdin Read input from standard input instead of from files
39+-o --output Write the generated Javascript to the specified file
40+-e --foreign imports Write a list of foreign imports declarations to the specified file in addition to generating Javascript output
41+--runtime-type-checks Generate simple runtime type checks for function arguments with simple types.
42+--tco Perform tail-call elimination on the generated Javascript.
43+--no-prelude Do not include the Prelude in the generated Javascript.
44+--magic-do Overload the `do` keyword to inline calls to `bind` for the `Eff` monad, to generate more efficient code.
45+--run-main Generate a call to `Main.main` after all other generated Javascript.
46+
47+Motivation
48+----------
6049
6150I was looking for a simple functional language which would compile to JavaScript and have the following characteristics:
6251
@@ -72,46 +61,40 @@ PureScript is *not* designed to be a general-purpose programming language. The p
7261
7362PureScript can also be seen as a trade-off between a theoretically ideal language and one which generates reasonably high performance code.
7463
75−## Hello, PureScript!
76−
77−As an introductory example, here is the usual "Hello World" written in PureScript:
78−
79−```haskell
80−module Main where
81−
82−import Trace
64+Hello, PureScript!
65+------------------
8366
84−main = trace "Hello, World!"
85−```
67+As an introductory example, here is the usual "Hello World" written in PureScript::
8668
87−which compiles to the following Javascript, ignoring the Prelude:
69+ module Main where
70+
71+ import Trace
72+
73+ main = trace "Hello, World!"
8874
89−```javascript
90−var Main;
91−(function (Main) {
92− var main = trace("Hello, World!");
93− Main.main = main;
94−})(Main = Main || {});
95−```
75+which compiles to the following Javascript, ignoring the Prelude::
9676
97−The following command will compile and execute the PureScript code above:
77+ var Main;
78+ (function (Main) {
79+ var main = trace("Hello, World!");
80+ Main.main = main;
81+ })(Main = Main || {});
9882
99−```
100−psc input.purs --run-main | nodejs
101−```
83+The following command will compile and execute the PureScript code above::
10284
103−## Another Example
85+ psc input.purs --run-main | nodejs
10486
105−The following code defines a `Person` data type and a function to generate a string representation for a `Person`:
87+Another Example
88+---------------
10689
107−```haskell
108−data Person = Person { name :: String, age :: Number }
90+The following code defines a `Person` data type and a function to generate a string representation for a `Person`::
10991
110−foreign import numberToString :: Number -> String
111−
112−showPerson :: Person -> String
113−showPerson (Person o) = o.name ++ ", aged " ++ numberToString(o.age)
114−```
92+ data Person = Person { name :: String, age :: Number }
93+
94+ foreign import numberToString :: Number -> String
95+
96+ showPerson :: Person -> String
97+ showPerson (Person o) = o.name ++ ", aged " ++ numberToString(o.age)
11598
11699Line by line, this reads as follows:
117100
@@ -121,18 +104,12 @@ Line by line, this reads as follows:
121104- The `showPerson` function takes a `Person` and returns a `String`
122105- `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.
123106
124−The generated Javascript looks like this:
125−
126−```javascript
127−var Person = function (value) {
128− return { ctor: 'Person', value: value };
129−};
130−
131−function showPerson(_1) {
132− if (_1.ctor === "Person") {
133− return _1.value.name + ", aged " + numberToString(_1.value.age);
134− };
135− throw "Failed pattern match";
136−};
107+The generated Javascript looks like this::
137108
138−```
109+ var Person = function (value) {
110+ return { ctor: 'Person', value: value };
111+ };
112+
113+ function showPerson(_1) {
114+ return _1.value.name + ", aged " + numberToString(_1.value.age);
115+ };