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

Update to and for PureScript 0.11 #63

Merged
merged 4 commits into from
Apr 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: node_js
dist: trusty
sudo: required
node_js: stable
install:
- npm install -g bower
- bower install
- npm install
script:
- npm run -s test
56 changes: 26 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ var gulp = require('gulp');

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

gulp.task('psc', function(){
return purescript.psc({
gulp.task('make', function(){
return purescript.compile({
src: 'src/*.purs'
});
});
Expand All @@ -34,27 +34,19 @@ There is also [a more complete example](#full-example) that makes use of all the

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.

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

### `purescript.psc(options)`
### `purescript.compile(options)`

Invokes the `psc` command. The following options are supported.
Invokes the `purs compile` command. The following options are supported.

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

Files to compile. Glob syntax is supported.

###### `noTco` (Boolean)

Toggles `--no-tco` that disables tail-call optimizations.

###### `noMagicDo` (Boolean)

Toggles `--no-magic-do` that disables optimizations overloading the do keyword generating efficient code for the `Eff` monad.

###### `noOpts` (Boolean)
###### `output` (String)

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

###### `verboseErrors` (Boolean)

Expand All @@ -64,29 +56,29 @@ Toggles `--verbose-errors` that displays verbose error messages.

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

###### `output` (String)
###### `sourceMaps` (Boolean)

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

###### `noPrefix` (Boolean)
###### `dumpCoreFn` (Boolean)

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

###### `sourceMaps` (Boolean)
###### `noPrefix` (Boolean)

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

###### `jsonErrors` (Boolean)

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

### `purescript.pscBundle(options)`
### `purescript.bundle(options)`

Invokes the `psc-bundle` command. The following options are supported.
Invokes the `purs bundle` command. The following options are supported.

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

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

###### `output` (String)

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

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

### `purescript.pscDocs(options)`
###### `sourceMaps` (Boolean)

Toggles `--source-maps` that generates source maps.

### `purescript.docs(options)`

Invokes the `psc-docs` command. The following options are supported.
Invokes the `purs docs` command. The following options are supported.

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

Expand Down Expand Up @@ -147,15 +143,15 @@ var sources = [
];

gulp.task("make", function () {
return purescript.psc({ src: sources });
return purescript.compile({ src: sources });
});

gulp.task("bundle", ["make"], function () {
return purescript.pscBundle({ src: "output/**/*.js", output: "dist/bundle.js" });
return purescript.bundle({ src: "output/**/*.js", output: "dist/bundle.js" });
});

gulp.task("docs", function () {
return purescript.pscDocs({
return purescript.docs({
src: sources,
docgen: {
"Name.Of.Module1": "docs/Name/Of/Module1.md",
Expand All @@ -170,7 +166,7 @@ gulp.task("dotpsci", function () {
});

gulp.task("test", ["make"], function() {
return purescript.pscBundle({ src: "output/**/*.js", main: "Test.Main" })
return purescript.bundle({ src: "output/**/*.js", main: "Test.Main" })
.pipe(run("node"));
});

Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "gulp-purescript",
"private": true,
"dependencies": {
"purescript-aff": "~0.17.0",
"purescript-foreign": "~1.0.0"
"purescript-aff": "~3.0.0",
"purescript-foreign": "~4.0.0"
}
}
18 changes: 9 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

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

function psc(options) {
return gulpPurescript.psc(options)();
function compile(options) {
return gulpPurescript.compile(options)();
}

function pscBundle(options) {
return gulpPurescript.pscBundle(options)();
function bundle(options) {
return gulpPurescript.bundle(options)();
}

function pscDocs(options) {
return gulpPurescript.pscDocs(options)();
function docs(options) {
return gulpPurescript.docs(options)();
}

function psci(options) {
return gulpPurescript.psci(options)();
}

module.exports.psc = psc;
module.exports.compile = compile;

module.exports.pscBundle = pscBundle;
module.exports.bundle = bundle;

module.exports.pscDocs = pscDocs;
module.exports.docs = docs;

module.exports.psci = psci;
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,30 @@
"output"
],
"scripts": {
"psc": "psc 'src/**/*.purs' 'bower_components/purescript-*/src/**/*.purs'",
"test": "npm run psc && (node test/test.js | tap-spec)",
"prepublish": "rm -r output && npm run psc"
"build": "purs compile 'src/**/*.purs' 'bower_components/purescript-*/src/**/*.purs'",
"test": "npm run build && (node test/test.js | tap-spec)",
"prepublish": "rimraf output && npm run build"
},
"keywords": [
"gulpplugin",
"purescript"
],
"dependencies": {
"async": "^2.0.0-rc.5",
"camelcase": "^3.0.0",
"cross-spawn": "^4.0.0",
"glob": "^7.0.3",
"gulp-util": "^3.0.7",
"async": "^2.3.0",
"camelcase": "^4.1.0",
"cross-spawn": "^5.1.0",
"glob": "^7.1.1",
"gulp-util": "^3.0.8",
"logalot": "^2.1.0",
"resolve-bin": "^0.4.0",
"which": "^1.2.9"
"which": "^1.2.14"
},
"devDependencies": {
"gulp": "^3.9.1",
"purescript": "^0.9.1-rc.1",
"purescript": "^0.11.4",
"rimraf": "^2.6.1",
"tap-spec": "^4.1.1",
"tape": "^4.5.1",
"through2": "^2.0.1"
"tape": "^4.6.3",
"through2": "^2.0.3"
}
}
4 changes: 2 additions & 2 deletions src/GulpPurescript/ChildProcess.purs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ module GulpPurescript.ChildProcess
import Prelude

import Control.Monad.Aff (Aff, makeAff)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff (Eff, kind Effect)
import Control.Monad.Eff.Exception (Error)

import Data.Function.Uncurried (Fn4, runFn4)

foreign import data ChildProcess :: !
foreign import data ChildProcess :: Effect

spawn :: forall eff. String -> Array String -> Aff (cp :: ChildProcess | eff) String
spawn command args = makeAff $ runFn4 spawnFn command args
Expand Down
4 changes: 2 additions & 2 deletions src/GulpPurescript/Glob.purs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ module GulpPurescript.Glob
import Prelude (Unit, ($))

import Control.Monad.Aff (Aff, makeAff)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff (Eff, kind Effect)
import Control.Monad.Eff.Exception (Error)

import Data.Function.Uncurried (Fn3, runFn3)

foreign import data Glob :: !
foreign import data Glob :: Effect

glob :: forall eff. String -> Aff (glob :: Glob | eff) (Array String)
glob pattern = makeAff $ runFn3 globFn pattern
Expand Down
4 changes: 2 additions & 2 deletions src/GulpPurescript/Logalot.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module GulpPurescript.Logalot

import Prelude (Unit)

import Control.Monad.Eff (Eff)
import Control.Monad.Eff (Eff, kind Effect)

foreign import data Logalot :: !
foreign import data Logalot :: Effect

foreign import info :: forall eff. String -> Eff (logalot :: Logalot | eff) Unit
35 changes: 18 additions & 17 deletions src/GulpPurescript/OS.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,35 @@ module GulpPurescript.OS
, platform
) where

import Prelude (class Show, (<$>), (<>), const)
import Prelude

import Control.Monad.Eff (Eff)
import Control.Monad.Eff (Eff, kind Effect)
import Control.Monad.Eff.Exception.Unsafe (unsafeThrow)
import Control.Monad.Except (runExcept)

import Data.Either (either)
import Data.Foreign (Foreign)
import Data.Foreign.Class (class IsForeign, read)
import Data.Foreign (F, Foreign, readString)
import Data.Maybe (Maybe(..))

foreign import data OS :: !
foreign import data OS :: Effect

data Platform = Darwin | Linux | Win32

instance showPlatform :: Show Platform where
show a = case a of
Darwin -> "darwin"
Linux -> "linux"
Win32 -> "win32"

instance isForeignPlatform :: IsForeign Platform where
read a = (\a -> case a of
"darwin" -> Darwin
"linux" -> Linux
"win32" -> Win32
_ -> unsafeThrow ("Unhandled platform: " <> a)) <$> read a
show = case _ of
Darwin -> "darwin"
Linux -> "linux"
Win32 -> "win32"

readPlatform :: Foreign -> F Platform
readPlatform =
readString >=> case _ of
"darwin" -> pure Darwin
"linux" -> pure Linux
"win32" -> pure Win32
a -> unsafeThrow ("Unhandled platform: " <> a)

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

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