Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit a3ff904

Browse files
committed
Update compiler options
1 parent 3a63680 commit a3ff904

File tree

3 files changed

+34
-41
lines changed

3 files changed

+34
-41
lines changed

README.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ There is also [a more complete example](#full-example) that makes use of all the
3434

3535
Refer to the PureScript [compiler usage](https://github.com/purescript/purescript/wiki/Language-Guide:-Getting-Started#compiler-usage) section of the Github wiki for additional details on the behaviour of each option below.
3636

37-
Options can be passed to the Haskell runtime system for `psc` by passing a `--psc-rts-flags` argument to `gulp`. Any values that follow this flag will be passed through to the runtime. There is no need to include `+RTS`/`-RTS` options as these are inserted automatically. See [the GHC documentation](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/runtime-control.html#rts-opts-cmdline) for information on the available RTS options.
37+
Options can be passed to the Haskell runtime system for `purs` by passing a `--purs-rts-flags` argument to `gulp`. Any values that follow this flag will be passed through to the runtime. There is no need to include `+RTS`/`-RTS` options as these are inserted automatically. See [the GHC documentation](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/runtime-control.html#rts-opts-cmdline) for information on the available RTS options.
3838

3939
### `purescript.psc(options)`
4040

@@ -44,17 +44,9 @@ Invokes the `psc` command. The following options are supported.
4444

4545
Files to compile. Glob syntax is supported.
4646

47-
###### `noTco` (Boolean)
48-
49-
Toggles `--no-tco` that disables tail-call optimizations.
50-
51-
###### `noMagicDo` (Boolean)
52-
53-
Toggles `--no-magic-do` that disables optimizations overloading the do keyword generating efficient code for the `Eff` monad.
54-
55-
###### `noOpts` (Boolean)
47+
###### `output` (String)
5648

57-
Toggles `--no-opts` that skips the optimization phase.
49+
Sets `--output=<string>` the specifies the output directory, `output` by default.
5850

5951
###### `verboseErrors` (Boolean)
6052

@@ -64,25 +56,25 @@ Toggles `--verbose-errors` that displays verbose error messages.
6456

6557
Toggles `--comments` that includes comments in generated code.
6658

67-
###### `output` (String)
59+
###### `sourceMaps` (Boolean)
6860

69-
Sets `--output=<string>` the specifies the output directory, `output` by default.
61+
Toggles `--source-maps` that generates source maps.
7062

71-
###### `noPrefix` (Boolean)
63+
###### `dumpCoreFn` (Boolean)
7264

73-
Toggles `--no-prefix` that does not include the comment header.
65+
Toggles `--dump-corefn` that generates dumps the (functional) core representation of the compiled code at `output/*/corefn.json`.
7466

75-
###### `sourceMaps` (Boolean)
67+
###### `noPrefix` (Boolean)
7668

77-
Toggles `--source-maps` that generates source maps.
69+
Toggles `--no-prefix` that does not include the comment header.
7870

7971
###### `jsonErrors` (Boolean)
8072

8173
Toggles `--json-errors` that prints errors to stderr as JSON.
8274

8375
### `purescript.pscBundle(options)`
8476

85-
Invokes the `psc-bundle` command. The following options are supported.
77+
Invokes the `purs compile` command. The following options are supported.
8678

8779
###### `src` (String or String Array)
8880

@@ -104,9 +96,13 @@ Toggles `--main` or sets `--main=<string>` that generates code to run the `main`
10496

10597
Sets `--namespace=<string>` that specifies the namespace that PureScript modules will be exported to when running in the browser.
10698

99+
###### `sourceMaps` (Boolean)
100+
101+
Toggles `--source-maps` that generates source maps.
102+
107103
### `purescript.pscDocs(options)`
108104

109-
Invokes the `psc-docs` command. The following options are supported.
105+
Invokes the `purs docs` command. The following options are supported.
110106

111107
###### `src` (String or String Array)
112108

src/GulpPurescript/Options.purs

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ noMagicDoOpt = "no-magic-do"
3434
noMagicDoKey :: String
3535
noMagicDoKey = camelcaseFn noMagicDoOpt
3636

37-
noTcoOpt :: String
38-
noTcoOpt = "no-tco"
39-
40-
noTcoKey :: String
41-
noTcoKey = camelcaseFn noTcoOpt
42-
4337
verboseErrorsOpt :: String
4438
verboseErrorsOpt = "verbose-errors"
4539

@@ -76,6 +70,12 @@ sourceMapsOpt = "source-maps"
7670
sourceMapsKey :: String
7771
sourceMapsKey = camelcaseFn sourceMapsOpt
7872

73+
dumpCoreFnOpt :: String
74+
dumpCoreFnOpt = "dump-corefn"
75+
76+
dumpCoreFnKey :: String
77+
dumpCoreFnKey = "dumpCoreFn"
78+
7979
jsonErrorsOpt :: String
8080
jsonErrorsOpt = "json-errors"
8181

@@ -109,13 +109,11 @@ docgenKey = docgenOpt
109109
newtype Psc
110110
= Psc { src :: Either String (Array String)
111111
, output :: Maybe String
112-
, noTco :: Maybe Boolean
113-
, noMagicDo :: Maybe Boolean
114-
, noOpts :: Maybe Boolean
115112
, verboseErrors :: Maybe Boolean
116113
, comments :: Maybe Boolean
117-
, noPrefix :: Maybe Boolean
118114
, sourceMaps :: Maybe Boolean
115+
, dumpCoreFn :: Maybe Boolean
116+
, noPrefix :: Maybe Boolean
119117
, jsonErrors :: Maybe Boolean
120118
}
121119

@@ -125,6 +123,7 @@ newtype PscBundle
125123
, "module" :: Maybe (Either String (Array String))
126124
, main :: Maybe (Either Boolean String)
127125
, namespace :: Maybe String
126+
, sourceMaps :: Maybe Boolean
128127
}
129128

130129
newtype PscDocs
@@ -146,15 +145,13 @@ readPsc :: Foreign -> F Psc
146145
readPsc obj = do
147146
src <- readSources =<< readProp srcKey obj
148147
output <- readPropNU readString outputKey obj
149-
noTco <- readPropNU readBoolean noTcoKey obj
150-
noMagicDo <- readPropNU readBoolean noMagicDoKey obj
151-
noOpts <- readPropNU readBoolean noOptsKey obj
152148
verboseErrors <- readPropNU readBoolean verboseErrorsKey obj
153149
comments <- readPropNU readBoolean commentsKey obj
154-
noPrefix <- readPropNU readBoolean noPrefixKey obj
155150
sourceMaps <- readPropNU readBoolean sourceMapsKey obj
151+
dumpCoreFn <- readPropNU readBoolean dumpCoreFnKey obj
152+
noPrefix <- readPropNU readBoolean noPrefixKey obj
156153
jsonErrors <- readPropNU readBoolean jsonErrorsKey obj
157-
pure $ Psc { src, output, noTco, noMagicDo, noOpts, verboseErrors, comments, noPrefix, sourceMaps, jsonErrors }
154+
pure $ Psc { src, output, verboseErrors, comments, sourceMaps, dumpCoreFn, noPrefix, jsonErrors }
158155

159156
readPscBundle :: Foreign -> F PscBundle
160157
readPscBundle obj = do
@@ -163,7 +160,8 @@ readPscBundle obj = do
163160
mod <- readPropNU readSources moduleKey obj
164161
main <- readPropNU (readEither readBoolean readString) mainKey obj
165162
namespace <- readPropNU readString namespaceKey obj
166-
pure $ PscBundle { src, output, "module": mod, main, namespace }
163+
sourceMaps <- readPropNU readBoolean sourceMapsKey obj
164+
pure $ PscBundle { src, output, "module": mod, main, namespace, sourceMaps }
167165

168166
readPscDocs :: Foreign -> F PscDocs
169167
readPscDocs obj = do
@@ -243,13 +241,11 @@ pscOptions opts = fold <$> parsed
243241
fold :: Psc -> Array String
244242
fold (Psc a) = either pure id a.src <>
245243
opt outputOpt a.output <>
246-
opt noTcoOpt a.noTco <>
247-
opt noMagicDoOpt a.noMagicDo <>
248-
opt noOptsOpt a.noOpts <>
249244
opt verboseErrorsOpt a.verboseErrors <>
250245
opt commentsOpt a.comments <>
251-
opt noPrefixOpt a.noPrefix <>
252246
opt sourceMapsOpt a.sourceMaps <>
247+
opt dumpCoreFnOpt a.dumpCoreFn <>
248+
opt noPrefixOpt a.noPrefix <>
253249
opt jsonErrorsOpt a.jsonErrors
254250

255251
pscBundleOptions :: Foreign -> F (Array String)
@@ -263,7 +259,8 @@ pscBundleOptions opts = fold <$> parsed
263259
opt outputOpt a.output <>
264260
opt moduleOpt a."module" <>
265261
opt mainOpt a.main <>
266-
opt namespaceOpt a.namespace
262+
opt namespaceOpt a.namespace <>
263+
opt sourceMapsOpt a.sourceMaps
267264

268265
pscDocsOptions :: Foreign -> F (Array String)
269266
pscDocsOptions opts = fold <$> parsed

src/GulpPurescript/Plugin.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ foreign import argv :: Array String
4242

4343
rtsOpts :: Array String
4444
rtsOpts =
45-
let startIndex = Array.elemIndex "--psc-rts-flags" argv
45+
let startIndex = Array.elemIndex "--purs-rts-flags" argv
4646
in case startIndex of
4747
Just i -> ["+RTS"] <> Array.drop (i + 1) argv <> ["-RTS"]
4848
_ -> []

0 commit comments

Comments
 (0)