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

Commit 19ac7b3

Browse files
authored
Merge pull request #63 from garyb/ps-0.11
Update to and for PureScript 0.11
2 parents e461fa9 + dbb8ce7 commit 19ac7b3

15 files changed

+274
-277
lines changed

.travis.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: node_js
2+
dist: trusty
3+
sudo: required
4+
node_js: stable
5+
install:
6+
- npm install -g bower
7+
- bower install
8+
- npm install
9+
script:
10+
- npm run -s test

README.md

+26-30
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ var gulp = require('gulp');
2121

2222
var purescript = require('gulp-purescript');
2323

24-
gulp.task('psc', function(){
25-
return purescript.psc({
24+
gulp.task('make', function(){
25+
return purescript.compile({
2626
src: 'src/*.purs'
2727
});
2828
});
@@ -34,27 +34,19 @@ 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

39-
### `purescript.psc(options)`
39+
### `purescript.compile(options)`
4040

41-
Invokes the `psc` command. The following options are supported.
41+
Invokes the `purs compile` command. The following options are supported.
4242

4343
###### `src` (String or String Array)
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,29 +56,29 @@ 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

83-
### `purescript.pscBundle(options)`
75+
### `purescript.bundle(options)`
8476

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

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

89-
The `psc`-produced JavaScript source files to bundle. Glob syntax is supported.
81+
The `purs compile`-produced JavaScript source files to bundle. Glob syntax is supported.
9082

9183
###### `output` (String)
9284

@@ -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

107-
### `purescript.pscDocs(options)`
99+
###### `sourceMaps` (Boolean)
100+
101+
Toggles `--source-maps` that generates source maps.
102+
103+
### `purescript.docs(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

@@ -147,15 +143,15 @@ var sources = [
147143
];
148144

149145
gulp.task("make", function () {
150-
return purescript.psc({ src: sources });
146+
return purescript.compile({ src: sources });
151147
});
152148

153149
gulp.task("bundle", ["make"], function () {
154-
return purescript.pscBundle({ src: "output/**/*.js", output: "dist/bundle.js" });
150+
return purescript.bundle({ src: "output/**/*.js", output: "dist/bundle.js" });
155151
});
156152

157153
gulp.task("docs", function () {
158-
return purescript.pscDocs({
154+
return purescript.docs({
159155
src: sources,
160156
docgen: {
161157
"Name.Of.Module1": "docs/Name/Of/Module1.md",
@@ -170,7 +166,7 @@ gulp.task("dotpsci", function () {
170166
});
171167

172168
gulp.task("test", ["make"], function() {
173-
return purescript.pscBundle({ src: "output/**/*.js", main: "Test.Main" })
169+
return purescript.bundle({ src: "output/**/*.js", main: "Test.Main" })
174170
.pipe(run("node"));
175171
});
176172

bower.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gulp-purescript",
33
"private": true,
44
"dependencies": {
5-
"purescript-aff": "~0.17.0",
6-
"purescript-foreign": "~1.0.0"
5+
"purescript-aff": "~3.0.0",
6+
"purescript-foreign": "~4.0.0"
77
}
88
}

index.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22

33
var gulpPurescript = require('./output/GulpPurescript.Plugin');
44

5-
function psc(options) {
6-
return gulpPurescript.psc(options)();
5+
function compile(options) {
6+
return gulpPurescript.compile(options)();
77
}
88

9-
function pscBundle(options) {
10-
return gulpPurescript.pscBundle(options)();
9+
function bundle(options) {
10+
return gulpPurescript.bundle(options)();
1111
}
1212

13-
function pscDocs(options) {
14-
return gulpPurescript.pscDocs(options)();
13+
function docs(options) {
14+
return gulpPurescript.docs(options)();
1515
}
1616

1717
function psci(options) {
1818
return gulpPurescript.psci(options)();
1919
}
2020

21-
module.exports.psc = psc;
21+
module.exports.compile = compile;
2222

23-
module.exports.pscBundle = pscBundle;
23+
module.exports.bundle = bundle;
2424

25-
module.exports.pscDocs = pscDocs;
25+
module.exports.docs = docs;
2626

2727
module.exports.psci = psci;

package.json

+13-12
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,30 @@
1717
"output"
1818
],
1919
"scripts": {
20-
"psc": "psc 'src/**/*.purs' 'bower_components/purescript-*/src/**/*.purs'",
21-
"test": "npm run psc && (node test/test.js | tap-spec)",
22-
"prepublish": "rm -r output && npm run psc"
20+
"build": "purs compile 'src/**/*.purs' 'bower_components/purescript-*/src/**/*.purs'",
21+
"test": "npm run build && (node test/test.js | tap-spec)",
22+
"prepublish": "rimraf output && npm run build"
2323
},
2424
"keywords": [
2525
"gulpplugin",
2626
"purescript"
2727
],
2828
"dependencies": {
29-
"async": "^2.0.0-rc.5",
30-
"camelcase": "^3.0.0",
31-
"cross-spawn": "^4.0.0",
32-
"glob": "^7.0.3",
33-
"gulp-util": "^3.0.7",
29+
"async": "^2.3.0",
30+
"camelcase": "^4.1.0",
31+
"cross-spawn": "^5.1.0",
32+
"glob": "^7.1.1",
33+
"gulp-util": "^3.0.8",
3434
"logalot": "^2.1.0",
3535
"resolve-bin": "^0.4.0",
36-
"which": "^1.2.9"
36+
"which": "^1.2.14"
3737
},
3838
"devDependencies": {
3939
"gulp": "^3.9.1",
40-
"purescript": "^0.9.1-rc.1",
40+
"purescript": "^0.11.4",
41+
"rimraf": "^2.6.1",
4142
"tap-spec": "^4.1.1",
42-
"tape": "^4.5.1",
43-
"through2": "^2.0.1"
43+
"tape": "^4.6.3",
44+
"through2": "^2.0.3"
4445
}
4546
}

src/GulpPurescript/ChildProcess.purs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ module GulpPurescript.ChildProcess
66
import Prelude
77

88
import Control.Monad.Aff (Aff, makeAff)
9-
import Control.Monad.Eff (Eff)
9+
import Control.Monad.Eff (Eff, kind Effect)
1010
import Control.Monad.Eff.Exception (Error)
1111

1212
import Data.Function.Uncurried (Fn4, runFn4)
1313

14-
foreign import data ChildProcess :: !
14+
foreign import data ChildProcess :: Effect
1515

1616
spawn :: forall eff. String -> Array String -> Aff (cp :: ChildProcess | eff) String
1717
spawn command args = makeAff $ runFn4 spawnFn command args

src/GulpPurescript/Glob.purs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ module GulpPurescript.Glob
77
import Prelude (Unit, ($))
88

99
import Control.Monad.Aff (Aff, makeAff)
10-
import Control.Monad.Eff (Eff)
10+
import Control.Monad.Eff (Eff, kind Effect)
1111
import Control.Monad.Eff.Exception (Error)
1212

1313
import Data.Function.Uncurried (Fn3, runFn3)
1414

15-
foreign import data Glob :: !
15+
foreign import data Glob :: Effect
1616

1717
glob :: forall eff. String -> Aff (glob :: Glob | eff) (Array String)
1818
glob pattern = makeAff $ runFn3 globFn pattern

src/GulpPurescript/Logalot.purs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ module GulpPurescript.Logalot
55

66
import Prelude (Unit)
77

8-
import Control.Monad.Eff (Eff)
8+
import Control.Monad.Eff (Eff, kind Effect)
99

10-
foreign import data Logalot :: !
10+
foreign import data Logalot :: Effect
1111

1212
foreign import info :: forall eff. String -> Eff (logalot :: Logalot | eff) Unit

src/GulpPurescript/OS.purs

+18-17
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,35 @@ module GulpPurescript.OS
44
, platform
55
) where
66

7-
import Prelude (class Show, (<$>), (<>), const)
7+
import Prelude
88

9-
import Control.Monad.Eff (Eff)
9+
import Control.Monad.Eff (Eff, kind Effect)
1010
import Control.Monad.Eff.Exception.Unsafe (unsafeThrow)
11+
import Control.Monad.Except (runExcept)
1112

1213
import Data.Either (either)
13-
import Data.Foreign (Foreign)
14-
import Data.Foreign.Class (class IsForeign, read)
14+
import Data.Foreign (F, Foreign, readString)
1515
import Data.Maybe (Maybe(..))
1616

17-
foreign import data OS :: !
17+
foreign import data OS :: Effect
1818

1919
data Platform = Darwin | Linux | Win32
2020

2121
instance showPlatform :: Show Platform where
22-
show a = case a of
23-
Darwin -> "darwin"
24-
Linux -> "linux"
25-
Win32 -> "win32"
26-
27-
instance isForeignPlatform :: IsForeign Platform where
28-
read a = (\a -> case a of
29-
"darwin" -> Darwin
30-
"linux" -> Linux
31-
"win32" -> Win32
32-
_ -> unsafeThrow ("Unhandled platform: " <> a)) <$> read a
22+
show = case _ of
23+
Darwin -> "darwin"
24+
Linux -> "linux"
25+
Win32 -> "win32"
26+
27+
readPlatform :: Foreign -> F Platform
28+
readPlatform =
29+
readString >=> case _ of
30+
"darwin" -> pure Darwin
31+
"linux" -> pure Linux
32+
"win32" -> pure Win32
33+
a -> unsafeThrow ("Unhandled platform: " <> a)
3334

3435
platform :: forall eff. Eff (os :: OS | eff) (Maybe Platform)
35-
platform = either (const Nothing) Just <$> read <$> platformFn
36+
platform = either (const Nothing) Just <$> runExcept <$> readPlatform <$> platformFn
3637

3738
foreign import platformFn :: forall eff. Eff (os :: OS | eff) Foreign

0 commit comments

Comments
 (0)