forked from purescript/purescript-refs
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRef.js
More file actions
37 lines (33 loc) · 644 Bytes
/
Copy pathRef.js
File metadata and controls
37 lines (33 loc) · 644 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
export const _new = function (val) {
return function () {
return { value: val };
};
};
export const newWithSelf = function (f) {
return function () {
var ref = { value: null };
ref.value = f(ref);
return ref;
};
};
export const read = function (ref) {
return function () {
return ref.value;
};
};
export const modifyImpl = function (f) {
return function (ref) {
return function () {
var t = f(ref.value);
ref.value = t.state;
return t.value;
};
};
};
export const write = function (val) {
return function (ref) {
return function () {
ref.value = val;
};
};
};