Skip to content

Commit

Permalink
Merge pull request #11 from slamdata/compiler/0.12
Browse files Browse the repository at this point in the history
Compiler/0.12
  • Loading branch information
garyb authored May 25, 2018
2 parents bf4fe9c + f302015 commit 1791441
Show file tree
Hide file tree
Showing 9 changed files with 432 additions and 336 deletions.
28 changes: 28 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"parserOptions": {
"ecmaVersion": 5
},
"extends": "eslint:recommended",
"env": {
"commonjs": true
},
"rules": {
"strict": [2, "global"],
"block-scoped-var": 2,
"consistent-return": 2,
"eqeqeq": [2, "smart"],
"guard-for-in": 2,
"no-caller": 2,
"no-extend-native": 2,
"no-loop-func": 2,
"no-new": 2,
"no-param-reassign": 2,
"no-return-assign": 2,
"no-unused-expressions": 2,
"no-use-before-define": 2,
"radix": [2, "always"],
"indent": [2, 2],
"quotes": [2, "double"],
"semi": [2, "always"]
}
}
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# purescript-avar
Low-level interface for asynchronous variables

[![Latest release](http://img.shields.io/github/release/slamdata/purescript-avar.svg)](https://github.com/slamdata/purescript-avar/releases)
[![Build status](https://travis-ci.org/slamdata/purescript-avar.svg?branch=master)](https://travis-ci.org/slamdata/purescript-avar)

Low-level interface for asynchronous variables.

## Installation

```
bower install purescript-avar
```

## Documentation

Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-avar).

19 changes: 10 additions & 9 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@
"tests"
],
"dependencies": {
"purescript-eff": "^3.1.0",
"purescript-maybe": "^3.0.0",
"purescript-either": "^3.1.0",
"purescript-functions": "^3.0.0",
"purescript-exceptions": "^3.0.0"
"purescript-aff": "^5.0.0",
"purescript-effect": "^2.0.0",
"purescript-maybe": "^4.0.0",
"purescript-either": "^4.0.0",
"purescript-functions": "^4.0.0",
"purescript-exceptions": "^4.0.0"
},
"devDependencies": {
"purescript-assert": "^3.0.0",
"purescript-console": "^3.0.0",
"purescript-transformers": "^3.4.0",
"purescript-refs": "^3.0.0"
"purescript-assert": "^4.0.0",
"purescript-console": "^4.1.0",
"purescript-transformers": "^4.0.0",
"purescript-refs": "^4.0.0"
}
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"private": true,
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "jshint src --verbose && pulp build -- --censor-lib --strict",
"build": "eslint src && pulp build -- --censor-lib --strict",
"test": "pulp test"
},
"devDependencies": {
"jshint": "^2.9.5",
"pulp": "^11.0.0",
"purescript-psa": "^0.5.1",
"purescript": "^0.11.5",
"rimraf": "^2.6.1"
"eslint": "^4.19.1",
"pulp": "^12.2.0",
"purescript-psa": "^0.6.0",
"purescript": "slamdata/node-purescript#0.12",
"rimraf": "^2.6.2"
}
}
150 changes: 0 additions & 150 deletions src/Control/Monad/Eff/AVar.purs

This file was deleted.

38 changes: 17 additions & 21 deletions src/Control/Monad/Eff/AVar.js → src/Effect/AVar.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* globals exports, setTimeout */
/* jshint -W097 */

"use strict";

var AVar = function () {

function MutableQueue () {
this.head = null;
this.last = null;
Expand All @@ -28,6 +27,16 @@ var AVar = function () {

var EMPTY = {};

function runEff(eff) {
try {
eff();
} catch (error) {
setTimeout(function () {
throw error;
}, 0);
}
}

function putLast (queue, value) {
var cell = new MutableCell(queue, value);
switch (queue.size) {
Expand Down Expand Up @@ -136,8 +145,7 @@ var AVar = function () {

avar.draining = true;

/* jshint -W084 */
while (1) {
while (1) { // eslint-disable-line no-constant-condition
p = null;
r = null;
t = null;
Expand All @@ -146,13 +154,13 @@ var AVar = function () {

if (avar.error !== null) {
value = util.left(avar.error);
while (p = takeHead(ps)) {
while (p = takeHead(ps)) { // eslint-disable-line no-cond-assign
runEff(p.cb(value));
}
while (r = takeHead(rs)) {
while (r = takeHead(rs)) { // eslint-disable-line no-cond-assign
runEff(r(value));
}
while (t = takeHead(ts)) {
while (t = takeHead(ts)) { // eslint-disable-line no-cond-assign
runEff(t(value));
}
break;
Expand Down Expand Up @@ -190,21 +198,9 @@ var AVar = function () {
break;
}
}
/* jshint +W084 */

avar.draining = false;
}

function runEff(eff) {
try {
eff();
} catch (error) {
setTimeout(function () {
throw error;
}, 0);
}
}

AVar.EMPTY = EMPTY;
AVar.putLast = putLast;
AVar.takeLast = takeLast;
Expand All @@ -215,11 +211,11 @@ var AVar = function () {
return AVar;
}();

exports.makeEmptyVar = function () {
exports.empty = function () {
return new AVar(AVar.EMPTY);
};

exports.makeVar = function (value) {
exports._newVar = function (value) {
return function () {
return new AVar(value);
};
Expand Down
Loading

0 comments on commit 1791441

Please sign in to comment.