Skip to content

Commit 72506ed

Browse files
committed
Updates for 0.7
1 parent 2936289 commit 72506ed

File tree

12 files changed

+277
-130
lines changed

12 files changed

+277
-130
lines changed

.gitignore

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
output
2-
bower_components
3-
.psci
4-
.psci_modules
1+
/.*
2+
!/.gitignore
3+
!/.jscsrc
4+
!/.jshintrc
5+
!/.travis.yml
6+
/bower_components/
7+
/node_modules/
8+
/output/

.jscsrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"preset": "grunt",
3+
"disallowSpacesInAnonymousFunctionExpression": null,
4+
"requireSpacesInAnonymousFunctionExpression": {
5+
"beforeOpeningRoundBrace": true,
6+
"beforeOpeningCurlyBrace": true
7+
},
8+
"disallowSpacesInsideObjectBrackets": null,
9+
"requireSpacesInsideObjectBrackets": "all",
10+
"validateQuoteMarks": "\"",
11+
"requireCurlyBraces": null
12+
}

.jshintrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"bitwise": true,
3+
"eqeqeq": true,
4+
"forin": true,
5+
"freeze": true,
6+
"funcscope": true,
7+
"futurehostile": true,
8+
"globalstrict": true,
9+
"latedef": true,
10+
"maxparams": 1,
11+
"noarg": true,
12+
"nocomma": true,
13+
"nonew": true,
14+
"notypeof": true,
15+
"singleGroups": true,
16+
"undef": true,
17+
"unused": true,
18+
"eqnull": true
19+
}

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: node_js
2+
node_js:
3+
- 0.10
4+
env:
5+
- PATH=$HOME/purescript:$PATH
6+
install:
7+
- TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p')
8+
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
9+
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
10+
- chmod a+x $HOME/purescript
11+
- npm install bower gulp -g
12+
- npm install && bower install
13+
script:
14+
- gulp

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 PureScript
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 7 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,15 @@
1-
# Important notice
1+
# purescript-st
22

3-
This module should not yet be depended on, it is for the upcoming 0.7 compiler release.
3+
[![Build Status](https://travis-ci.org/purescript/purescript-st.svg?branch=master)](https://travis-ci.org/purescript/purescript-st)
44

5-
# Module Documentation
5+
The ST effect, for safe local mutation. For use with compiler version >= 0.7.
66

7-
## Module Control.Monad.ST
7+
## Installation
88

9-
#### `ST`
10-
11-
``` purescript
12-
data ST :: * -> !
13-
```
14-
15-
The `ST` effect represents _local mutation_, i.e. mutation which does not "escape" into the surrounding computation.
16-
17-
An `ST` computation is parameterized by a phantom type which is used to restrict the set of reference cells it is allowed to access.
18-
19-
The `runST` function can be used to handle the `ST` effect.
20-
21-
#### `STRef`
22-
23-
``` purescript
24-
data STRef :: * -> * -> *
25-
```
26-
27-
The type `STRef s a` represents a mutable reference holding a value of type `a`, which can be used with the `ST s` effect.
28-
29-
#### `newSTRef`
30-
31-
``` purescript
32-
newSTRef :: forall a h r. a -> Eff (st :: ST h | r) (STRef h a)
339
```
34-
35-
Create a new mutable reference.
36-
37-
#### `readSTRef`
38-
39-
``` purescript
40-
readSTRef :: forall a h r. STRef h a -> Eff (st :: ST h | r) a
41-
```
42-
43-
Read the current value of a mutable reference.
44-
45-
#### `modifySTRef`
46-
47-
``` purescript
48-
modifySTRef :: forall a h r. STRef h a -> (a -> a) -> Eff (st :: ST h | r) a
10+
bower install purescript-st
4911
```
5012

51-
Modify the value of a mutable reference by applying a function to the current value.
52-
53-
#### `writeSTRef`
54-
55-
``` purescript
56-
writeSTRef :: forall a h r. STRef h a -> a -> Eff (st :: ST h | r) a
57-
```
58-
59-
Set the value of a mutable reference.
60-
61-
#### `runST`
62-
63-
``` purescript
64-
runST :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
65-
```
66-
67-
Run an `ST` computation.
68-
69-
Note: the type of `runST` uses a rank-2 type to constrain the phantom type `s`, such that the computation must not leak any mutable references
70-
to the surrounding computation.
71-
72-
It may cause problems to apply this function using the `$` operator. The recommended approach is to use parentheses instead.
73-
74-
#### `pureST`
75-
76-
``` purescript
77-
pureST :: forall a. (forall h r. Eff (st :: ST h | r) a) -> a
78-
```
79-
80-
A convenience function which combines `runST` with `runPure`, which can be used when the only required effect is `ST`.
81-
82-
Note: since this function has a rank-2 type, it may cause problems to apply this function using the `$` operator. The recommended approach
83-
is to use parentheses instead.
84-
85-
13+
## Module documentation
8614

15+
- [Control.Monad.ST](docs/Control.Monad.ST.md)

bower.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
{
22
"name": "purescript-st",
3-
"version": "0.1.0",
4-
"moduleType": [
5-
"node"
3+
"homepage": "https://github.com/purescript/purescript-st",
4+
"description": "The ST effect, for safe local mutation",
5+
"keywords": [
6+
"purescript"
67
],
8+
"license": "MIT",
9+
"repository": {
10+
"type": "git",
11+
"url": "git://github.com/purescript/purescript-st.git"
12+
},
713
"ignore": [
814
"**/.*",
9-
"node_modules",
1015
"bower_components",
11-
"output"
16+
"node_modules",
17+
"output",
18+
"test",
19+
"bower.json",
20+
"gulpfile.js",
21+
"package.json"
1222
],
1323
"dependencies": {
1424
"purescript-eff": "~0.1.0"

docs/Control.Monad.ST.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
## Module Control.Monad.ST
2+
3+
#### `ST`
4+
5+
``` purescript
6+
data ST :: * -> !
7+
```
8+
9+
The `ST` effect represents _local mutation_, i.e. mutation which does not "escape" into the surrounding computation.
10+
11+
An `ST` computation is parameterized by a phantom type which is used to restrict the set of reference cells it is allowed to access.
12+
13+
The `runST` function can be used to handle the `ST` effect.
14+
15+
#### `STRef`
16+
17+
``` purescript
18+
data STRef :: * -> * -> *
19+
```
20+
21+
The type `STRef s a` represents a mutable reference holding a value of type `a`, which can be used with the `ST s` effect.
22+
23+
#### `newSTRef`
24+
25+
``` purescript
26+
newSTRef :: forall a h r. a -> Eff (st :: ST h | r) (STRef h a)
27+
```
28+
29+
Create a new mutable reference.
30+
31+
#### `readSTRef`
32+
33+
``` purescript
34+
readSTRef :: forall a h r. STRef h a -> Eff (st :: ST h | r) a
35+
```
36+
37+
Read the current value of a mutable reference.
38+
39+
#### `modifySTRef`
40+
41+
``` purescript
42+
modifySTRef :: forall a h r. STRef h a -> (a -> a) -> Eff (st :: ST h | r) a
43+
```
44+
45+
Modify the value of a mutable reference by applying a function to the current value.
46+
47+
#### `writeSTRef`
48+
49+
``` purescript
50+
writeSTRef :: forall a h r. STRef h a -> a -> Eff (st :: ST h | r) a
51+
```
52+
53+
Set the value of a mutable reference.
54+
55+
#### `runST`
56+
57+
``` purescript
58+
runST :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
59+
```
60+
61+
Run an `ST` computation.
62+
63+
Note: the type of `runST` uses a rank-2 type to constrain the phantom type `s`, such that the computation must not leak any mutable references
64+
to the surrounding computation.
65+
66+
It may cause problems to apply this function using the `$` operator. The recommended approach is to use parentheses instead.
67+
68+
#### `pureST`
69+
70+
``` purescript
71+
pureST :: forall a. (forall h r. Eff (st :: ST h | r) a) -> a
72+
```
73+
74+
A convenience function which combines `runST` with `runPure`, which can be used when the only required effect is `ST`.
75+
76+
Note: since this function has a rank-2 type, it may cause problems to apply this function using the `$` operator. The recommended approach
77+
is to use parentheses instead.
78+
79+

gulpfile.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* jshint node: true */
2+
"use strict";
3+
4+
var gulp = require("gulp");
5+
var jshint = require("gulp-jshint");
6+
var jscs = require("gulp-jscs");
7+
var plumber = require("gulp-plumber");
8+
var purescript = require("gulp-purescript");
9+
10+
var sources = [
11+
"src/**/*.purs",
12+
"bower_components/purescript-*/src/**/*.purs"
13+
];
14+
15+
var foreigns = [
16+
"src/**/*.js",
17+
"bower_components/purescript-*/src/**/*.js"
18+
];
19+
20+
gulp.task("lint", function() {
21+
return gulp.src("src/**/*.js")
22+
.pipe(jshint())
23+
.pipe(jshint.reporter())
24+
.pipe(jscs());
25+
});
26+
27+
gulp.task("make", ["lint"], function() {
28+
return gulp.src(sources)
29+
.pipe(plumber())
30+
.pipe(purescript.pscMake({ ffi: foreigns }));
31+
});
32+
33+
gulp.task("docs", function () {
34+
return gulp.src(sources)
35+
.pipe(plumber())
36+
.pipe(purescript.pscDocs({
37+
docgen: {
38+
"Control.Monad.ST": "docs/Control.Monad.ST.md"
39+
}
40+
}));
41+
});
42+
43+
gulp.task("dotpsci", function () {
44+
return gulp.src(sources)
45+
.pipe(plumber())
46+
.pipe(purescript.dotPsci());
47+
});
48+
49+
gulp.task("default", ["make", "docs", "dotpsci"]);

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"private": true,
3+
"devDependencies": {
4+
"gulp": "^3.8.11",
5+
"gulp-jscs": "^1.6.0",
6+
"gulp-jshint": "^1.10.0",
7+
"gulp-plumber": "^1.0.0",
8+
"gulp-purescript": "^0.5.0"
9+
}
10+
}

0 commit comments

Comments
 (0)