Skip to content

Commit 5041ba4

Browse files
authored
Merge pull request #17 from purescript/compiler/0.12
Update for PureScript 0.12
2 parents b938bda + 0d9a1f9 commit 5041ba4

File tree

8 files changed

+69
-80
lines changed

8 files changed

+69
-80
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/bower_components/
66
/node_modules/
77
/output/
8+
package-lock.json

LICENSE

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
The MIT License (MIT)
1+
Copyright 2018 PureScript
22

3-
Copyright (c) 2014 PureScript
3+
Redistribution and use in source and binary forms, with or without modification,
4+
are permitted provided that the following conditions are met:
45

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:
6+
1. Redistributions of source code must retain the above copyright notice, this
7+
list of conditions and the following disclaimer.
118

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
9+
2. Redistributions in binary form must reproduce the above copyright notice,
10+
this list of conditions and the following disclaimer in the documentation and/or
11+
other materials provided with the distribution.
1412

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.
13+
3. Neither the name of the copyright holder nor the names of its contributors
14+
may be used to endorse or promote products derived from this software without
15+
specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

bower.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"name": "purescript-refs",
33
"homepage": "https://github.com/purescript/purescript-refs",
4-
"description": "Mutable value references",
5-
"license": "MIT",
4+
"license": "BSD-3-Clause",
65
"repository": {
76
"type": "git",
87
"url": "git://github.com/purescript/purescript-refs.git"
@@ -17,6 +16,7 @@
1716
"package.json"
1817
],
1918
"dependencies": {
20-
"purescript-eff": "^3.0.0"
19+
"purescript-effect": "^2.0.0",
20+
"purescript-prelude": "^4.0.0"
2121
}
2222
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"build": "eslint src && pulp build -- --censor-lib --strict"
66
},
77
"devDependencies": {
8-
"eslint": "^3.17.1",
9-
"pulp": "^10.0.4",
10-
"purescript-psa": "^0.5.0-rc.1",
11-
"rimraf": "^2.6.1"
8+
"eslint": "^4.19.1",
9+
"pulp": "^12.2.0",
10+
"purescript-psa": "^0.6.0",
11+
"rimraf": "^2.6.2"
1212
}
1313
}

src/Control/Monad/Eff/Ref.purs

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/Control/Monad/Eff/Ref/Unsafe.purs

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/Control/Monad/Eff/Ref.js renamed to src/Effect/Ref.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
"use strict";
22

3-
exports.newRef = function (val) {
3+
exports.new = function (val) {
44
return function () {
55
return { value: val };
66
};
77
};
88

9-
exports.readRef = function (ref) {
9+
exports.read = function (ref) {
1010
return function () {
1111
return ref.value;
1212
};
1313
};
1414

15-
exports["modifyRef'"] = function (ref) {
16-
return function (f) {
15+
exports["modify'"] = function (f) {
16+
return function (ref) {
1717
return function () {
1818
var t = f(ref.value);
1919
ref.value = t.state;
@@ -22,8 +22,8 @@ exports["modifyRef'"] = function (ref) {
2222
};
2323
};
2424

25-
exports.writeRef = function (ref) {
26-
return function (val) {
25+
exports.write = function (val) {
26+
return function (ref) {
2727
return function () {
2828
ref.value = val;
2929
return {};

src/Effect/Ref.purs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
-- | This module defines an effect and actions for working with
2+
-- | global mutable variables.
3+
-- |
4+
-- | _Note_: `Control.Monad.ST` provides a _safe_ alternative
5+
-- | to global mutable variables when mutation is restricted to a
6+
-- | local scope.
7+
module Effect.Ref where
8+
9+
import Prelude
10+
11+
import Effect (Effect)
12+
13+
-- | A value of type `Ref a` represents a mutable reference
14+
-- | which holds a value of type `a`.
15+
foreign import data Ref :: Type -> Type
16+
17+
-- | Create a new mutable reference containing the specified value.
18+
foreign import new :: forall s. s -> Effect (Ref s)
19+
20+
-- | Read the current value of a mutable reference
21+
foreign import read :: forall s. Ref s -> Effect s
22+
23+
-- | Update the value of a mutable reference by applying a function
24+
-- | to the current value.
25+
foreign import modify' :: forall s b. (s -> { state :: s, value :: b }) -> Ref s -> Effect b
26+
27+
-- | Update the value of a mutable reference by applying a function
28+
-- | to the current value. The updated value is returned.
29+
modify :: forall s. (s -> s) -> Ref s -> Effect s
30+
modify f = modify' \s -> let s' = f s in { state: s', value: s' }
31+
32+
-- | Update the value of a mutable reference to the specified value.
33+
foreign import write :: forall s. s -> Ref s -> Effect Unit

0 commit comments

Comments
 (0)