Skip to content

Commit

Permalink
Updates for RC
Browse files Browse the repository at this point in the history
  • Loading branch information
garyb committed Jun 9, 2015
1 parent 36270ad commit ea886bb
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 56 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/.*
!/.gitignore
!/.jscsrc
!/.jshintrc
!/.travis.yml
/bower_components/
/node_modules/
/output/
/tmp/
12 changes: 12 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"preset": "grunt",
"disallowSpacesInAnonymousFunctionExpression": null,
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInsideObjectBrackets": null,
"requireSpacesInsideObjectBrackets": "all",
"validateQuoteMarks": "\"",
"requireCurlyBraces": null
}
19 changes: 19 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"bitwise": true,
"eqeqeq": true,
"forin": true,
"freeze": true,
"funcscope": true,
"futurehostile": true,
"globalstrict": true,
"latedef": true,
"maxparams": 1,
"noarg": true,
"nocomma": true,
"nonew": true,
"notypeof": true,
"singleGroups": true,
"undef": true,
"unused": true,
"eqnull": true
}
19 changes: 14 additions & 5 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
{
"name": "purescript-semirings",
"moduleType": [
"node"
"name": "purescript-refs",
"homepage": "https://github.com/purescript/purescript-refs",
"description": "Mutable value references",
"keywords": [
"purescript"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/purescript/purescript-refs.git"
},
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"node_modules",
"output",
"test",
"bower.json",
"gulpfile.js",
"package.json"
],
"dependencies": {
"purescript-eff": "~0.1.0"
"purescript-eff": "^0.1.0",
"purescript-prelude": "^0.1.0"
}
}
18 changes: 18 additions & 0 deletions docs/Control.Monad.Eff.Ref.Unsafe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Module Control.Monad.Eff.Ref.Unsafe

Unsafe functions for working with mutable references.

#### `unsafeRunRef`

``` purescript
unsafeRunRef :: forall eff a. Eff (ref :: REF | eff) a -> Eff eff a
```

This handler function unsafely removes the `Ref` effect from an
effectful action.

This function might be used when it is impossible to prove to the
typechecker that a particular mutable reference does not escape
its scope.


6 changes: 1 addition & 5 deletions docs/Control.Monad.Eff.Ref.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Module Documentation

## Module Control.Monad.Eff.Ref


This module defines an effect and actions for working with
global mutable variables.

Expand Down Expand Up @@ -46,7 +43,7 @@ Read the current value of a mutable reference
#### `modifyRef'`

``` purescript
modifyRef' :: forall s b r. Ref s -> (s -> { value :: b, state :: s }) -> Eff (ref :: REF | r) b
modifyRef' :: forall s b r. Ref s -> (s -> { state :: s, value :: b }) -> Eff (ref :: REF | r) b
```

Update the value of a mutable reference by applying a function
Expand All @@ -70,4 +67,3 @@ writeRef :: forall s r. Ref s -> s -> Eff (ref :: REF | r) Unit
Update the value of a mutable reference to the specified value.



3 changes: 0 additions & 3 deletions docs/Control.Monad.Eff.Unsafe.md

This file was deleted.

63 changes: 38 additions & 25 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,61 @@
/* jshint node: true */
"use strict";

var gulp = require("gulp");
var jshint = require("gulp-jshint");
var jscs = require("gulp-jscs");
var plumber = require("gulp-plumber");
var purescript = require("gulp-purescript");
var jsvalidate = require("gulp-jsvalidate");
var rimraf = require("rimraf");

var paths = [
var sources = [
"src/**/*.purs",
"bower_components/purescript-*/src/**/*.purs"
];

gulp.task("make", function() {
return gulp.src(paths)
.pipe(plumber())
.pipe(purescript.pscMake());
var foreigns = [
"src/**/*.js",
"bower_components/purescript-*/src/**/*.js"
];

gulp.task("clean-docs", function (cb) {
rimraf("docs", cb);
});

gulp.task("jsvalidate", ["make"], function () {
return gulp.src("output/**/*.js")
.pipe(plumber())
.pipe(jsvalidate());
gulp.task("clean-output", function (cb) {
rimraf("output", cb);
});

var docTasks = [];
gulp.task("clean", ["clean-docs", "clean-output"]);

var docTask = function(name) {
var taskName = "docs-" + name.toLowerCase();
gulp.task(taskName, function () {
return gulp.src("src/" + name.replace(/\./g, "/") + ".purs")
.pipe(plumber())
.pipe(purescript.pscDocs())
.pipe(gulp.dest("docs/" + name + ".md"));
});
docTasks.push(taskName);
};
gulp.task("lint", function() {
return gulp.src("src/**/*.js")
.pipe(jshint())
.pipe(jshint.reporter())
.pipe(jscs());
});

["Control.Monad.Eff.Ref", "Control.Monad.Eff.Unsafe"].forEach(docTask);
gulp.task("make", ["lint"], function() {
return gulp.src(sources)
.pipe(plumber())
.pipe(purescript.pscMake({ ffi: foreigns }));
});

gulp.task("docs", docTasks);
gulp.task("docs", ["clean-docs"], function () {
return gulp.src(sources)
.pipe(plumber())
.pipe(purescript.pscDocs({
docgen: {
"Control.Monad.Eff.Ref": "docs/Control.Monad.Eff.Ref.md",
"Control.Monad.Eff.Ref.Unsafe": "docs/Control.Monad.Eff.Ref.Unsafe.md"
}
}));
});

gulp.task("dotpsci", function () {
return gulp.src(paths)
return gulp.src(sources)
.pipe(plumber())
.pipe(purescript.dotPsci());
});

gulp.task("default", ["jsvalidate", "docs", "dotpsci"]);
gulp.task("default", ["make", "docs", "dotpsci"]);
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
"private": true,
"devDependencies": {
"gulp": "^3.8.11",
"gulp-jsvalidate": "^1.0.1",
"gulp-jscs": "^1.6.0",
"gulp-jshint": "^1.10.0",
"gulp-plumber": "^1.0.0",
"gulp-purescript": "^0.3.1"
"gulp-purescript": "^0.5.0-rc.1",
"rimraf": "^2.3.3"
}
}
18 changes: 9 additions & 9 deletions src/Control/Monad/Eff/Ref.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@

// module Control.Monad.Eff.Ref

exports.newRef = function(val) {
exports.newRef = function (val) {
return function () {
return { value: val };
};
};

exports.readRef = function(ref) {
return function() {
exports.readRef = function (ref) {
return function () {
return ref.value;
};
};

exports.modifyRef$prime = function(ref) {
return function(f) {
return function() {
exports["modifyRef'"] = function (ref) {
return function (f) {
return function () {
var t = f(ref.value);
ref.value = t.state;
return t.value;
};
};
};

exports.writeRef = function(ref) {
return function(val) {
return function() {
exports.writeRef = function (ref) {
return function (val) {
return function () {
ref.value = val;
return {};
};
Expand Down
2 changes: 0 additions & 2 deletions src/Control/Monad/Eff/Ref.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
-- | _Note_: The `Control.Monad.ST` provides a _safe_ alternative
-- | to global mutable variables when mutation is restricted to a
-- | local scope.

module Control.Monad.Eff.Ref where

import Prelude

import Control.Monad.Eff (Eff())

-- | The effect associated with the use of global mutable variables.
Expand Down
5 changes: 1 addition & 4 deletions src/Control/Monad/Eff/Ref/Unsafe.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

module Control.Monad.Eff.Ref.Unsafe where

import Prelude

import Control.Monad.Eff (Eff())
import Control.Monad.Eff.Ref

import Control.Monad.Eff.Unsafe (unsafeInterleaveEff)

-- | This handler function unsafely removes the `Ref` effect from an
Expand All @@ -16,4 +13,4 @@ import Control.Monad.Eff.Unsafe (unsafeInterleaveEff)
-- | typechecker that a particular mutable reference does not escape
-- | its scope.
unsafeRunRef :: forall eff a. Eff (ref :: REF | eff) a -> Eff eff a
unsafeRunRef = unsafeInterleaveEff
unsafeRunRef = unsafeInterleaveEff

0 comments on commit ea886bb

Please sign in to comment.