You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Consolidate READMEs, remove some references to backends
* Update default gist ID
This one uses `gist.github.com` links for the examples so that the links
work.
* adjust heading levels
* Update link pointing to gh-pages branch
We probably won't be using this branch once we deploy the current
version, and everything is in the main repo README now anyway.
* Update README.md
Co-Authored-By: Thomas Honeyman <[email protected]>
* Update README.md
Co-Authored-By: Thomas Honeyman <[email protected]>
* Mention defaults with query string parameters
* Reword 200 response status rationale
Co-authored-by: Thomas Honeyman <[email protected]>
Very basic web service which wraps the PureScript compiler.
5
+
[Try PureScript](https://try.purescript.org) is an online PureScript code editor for quickly experimenting with PureScript code snippets and ideas. It consists of a client and a server component, both of which live within this repository.
- Writing code using the [Ace Editor](http://ace.c9.io)
10
+
- Automatic compilation
11
+
- PureScript syntax highlighting
12
+
- Run and print output or show resulting JavaScript
13
+
- Multiple view modes: code, output or both
14
+
- Persistent session
15
+
- Load PureScript code from Github Gists
10
16
11
-
### Compile PureScript code
12
-
13
-
**POST /compile**
14
-
15
-
- Request body: PureScript code
16
-
- Response body: Either `{ js: "..." }` or `{ error: "..." }`
17
-
- Status code: 200 (success)
17
+
### Control Features via the Query String
18
18
19
-
The response does not use error codes, to make it easier to use the API from another domain using CORS.
19
+
Most of these features can be controlled not only from the toolbar, but also using the [query parameters](https://en.wikipedia.org/wiki/Query_string):
20
20
21
-
The output code will contain references to preloaded modules using `require` calls. To run these files in the browser, it is necessary to either use a `require` shim (such as require1k), or replace these calls and deploy a bundle of precompiled modules (the Try PureScript client uses the second approach).
21
+
-**Load From Gist**: Load PureScript code from Gist id using the `gist` parameter
22
+
- Example: `gist=37c3c97f47a43f20c548` will load the code from this Gist if the file was named `Main.purs`
22
23
23
-
## Configuration
24
+
-**View Mode**: Control the view mode using the `view` parameter
25
+
- Options are: `code`, `output`, `both` (default)
26
+
- Example: `view=output` will only display the output
24
27
25
-
The application takes the following arguments on the command line:
28
+
-**Auto Compile**: Automatic compilation can be turned off using the `compile` parameter
29
+
- Options are: `true` (default), `false`
30
+
- Example: `compile=false` will turn auto compilation off
26
31
27
-
- port number
28
-
- a list of input source files
32
+
-**JavaScript Code Generation**: Print the resulting JavaScript code in the output window instead of the output of the program using the `js` parameter
33
+
- Options are: `true`, `false` (default)
34
+
- Example: `js=true` will print JavaScript code instead of the program's output
29
35
30
-
### Example
36
+
-**Session**: Load code from a session which is stored with [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) using the `session` parameter
37
+
- Usually managed by Try PureScript
38
+
- Example: `session=9162f098-070f-4053-60ea-eba47021450d` (Note: will probably not work for you)
39
+
- When used with the `gist` query parameter the code will be loaded from the Gist and not the session
# should output that is is compiling the sources (first time)
68
73
# then: Setting phasers to stun... (port 8081) (ctrl-c to quit)
69
74
```
70
75
71
-
## 3. Point client to local compile server
76
+
## Server API
72
77
73
-
(instead of the ones at try.purescript.org)
74
-
```
75
-
# edit API.purs
78
+
The server is a very basic web service which wraps the PureScript compiler, allowing clients to send PureScript code to be compiled and receiving either compiled JS or error messages in response.
- Response body: Either `{ js: "..." }` or `{ error: "..." }`
86
+
- Status code: 200 (success)
87
+
88
+
Note that if the code in the request body fails to compile, this is considered a success from the perspective of the API, so compilation failures will be returned with 2xx status codes.
89
+
Among other things, this makes it easier to use the API from another domain using CORS.
90
+
91
+
The output code will contain references to preloaded modules using `require` calls.
92
+
To run these files in the browser, it is necessary to either use a `require` shim (such as require1k), or replace these calls and deploy a bundle of precompiled modules.
93
+
The Try PureScript client uses the second approach.
94
+
95
+
### Configuration
96
+
97
+
The server application takes the following arguments on the command line:
0 commit comments