functionalscript 0.10.2 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cas/module.f.js +11 -9
- package/ci/module.f.d.ts +1 -1
- package/ci/module.f.js +5 -2
- package/dev/module.f.js +7 -3
- package/dev/version/module.f.js +6 -3
- package/package.json +1 -1
- package/types/effects/module.f.d.ts +0 -1
- package/types/effects/module.f.js +0 -1
- package/website/module.f.js +2 -2
package/cas/module.f.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { computeSync, sha256 } from "../crypto/sha2/module.f.js";
|
|
7
7
|
import { parse } from "../path/module.f.js";
|
|
8
8
|
import { cBase32ToVec, vecToCBase32 } from "../types/cbase32/module.f.js";
|
|
9
|
-
import { fluent } from "../types/effects/module.f.js";
|
|
9
|
+
import { fluent, pure } from "../types/effects/module.f.js";
|
|
10
10
|
import { error, log, mkdir, readdir, readFile, writeFile } from "../types/effects/node/module.f.js";
|
|
11
11
|
import { toOption } from "../types/nullable/module.f.js";
|
|
12
12
|
import { unwrap } from "../types/result/module.f.js";
|
|
@@ -22,7 +22,7 @@ const toPath = (key) => {
|
|
|
22
22
|
export const fileKvStore = (path) => ({
|
|
23
23
|
read: (key) => fluent
|
|
24
24
|
.step(() => readFile(toPath(key)))
|
|
25
|
-
.
|
|
25
|
+
.step(([status, data]) => pure(status === 'error' ? undefined : data))
|
|
26
26
|
.effect,
|
|
27
27
|
write: (key, value) => {
|
|
28
28
|
const p = toPath(key);
|
|
@@ -32,14 +32,16 @@ export const fileKvStore = (path) => ({
|
|
|
32
32
|
return fluent
|
|
33
33
|
.step(() => mkdir(dir, { recursive: true }))
|
|
34
34
|
.step(() => writeFile(`${path}/${p}`, value))
|
|
35
|
-
.
|
|
35
|
+
.step(() => pure(undefined))
|
|
36
36
|
.effect;
|
|
37
37
|
},
|
|
38
38
|
list: () =>
|
|
39
39
|
// TODO: remove unwrap
|
|
40
40
|
fluent
|
|
41
41
|
.step(() => readdir('.cas', { recursive: true }))
|
|
42
|
-
.
|
|
42
|
+
.step(r => pure(unwrap(r).flatMap(({ name, parentPath, isFile }) => toOption(isFile
|
|
43
|
+
? cBase32ToVec(parentPath.substring(prefix.length).replaceAll('/', '') + name)
|
|
44
|
+
: null))))
|
|
43
45
|
.effect,
|
|
44
46
|
});
|
|
45
47
|
export const cas = (sha2) => {
|
|
@@ -50,7 +52,7 @@ export const cas = (sha2) => {
|
|
|
50
52
|
const hash = compute([value]);
|
|
51
53
|
return fluent
|
|
52
54
|
.step(() => write(hash, value))
|
|
53
|
-
.
|
|
55
|
+
.step(() => pure(hash))
|
|
54
56
|
.effect;
|
|
55
57
|
},
|
|
56
58
|
list,
|
|
@@ -58,7 +60,7 @@ export const cas = (sha2) => {
|
|
|
58
60
|
};
|
|
59
61
|
const e = (s) => fluent
|
|
60
62
|
.step(() => error(s))
|
|
61
|
-
.
|
|
63
|
+
.step(() => pure(1))
|
|
62
64
|
.effect;
|
|
63
65
|
export const main = (args) => {
|
|
64
66
|
const c = cas(sha256)(fileKvStore('.'));
|
|
@@ -73,7 +75,7 @@ export const main = (args) => {
|
|
|
73
75
|
.step(() => readFile(path))
|
|
74
76
|
.step(v => c.write(unwrap(v)))
|
|
75
77
|
.step(hash => log(vecToCBase32(hash)))
|
|
76
|
-
.
|
|
78
|
+
.step(() => pure(0))
|
|
77
79
|
.effect;
|
|
78
80
|
}
|
|
79
81
|
case 'get': {
|
|
@@ -92,7 +94,7 @@ export const main = (args) => {
|
|
|
92
94
|
? e(`no such hash: ${hashCBase32}`)
|
|
93
95
|
: fluent
|
|
94
96
|
.step(() => writeFile(path, v))
|
|
95
|
-
.
|
|
97
|
+
.step(() => pure(0))
|
|
96
98
|
.effect;
|
|
97
99
|
return result;
|
|
98
100
|
})
|
|
@@ -113,7 +115,7 @@ export const main = (args) => {
|
|
|
113
115
|
}
|
|
114
116
|
return i;
|
|
115
117
|
})
|
|
116
|
-
.
|
|
118
|
+
.step(() => pure(0))
|
|
117
119
|
.effect;
|
|
118
120
|
}
|
|
119
121
|
case undefined: {
|
package/ci/module.f.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type NodeEffect } from '../types/effects/node/module.f.ts';
|
|
2
2
|
export declare const effect: NodeEffect<number>;
|
|
3
|
-
declare const _default: () => import("../types/effects/module.f.ts").Pure<number
|
|
3
|
+
declare const _default: () => import("../types/effects/module.f.ts").Pure<number>;
|
|
4
4
|
export default _default;
|
package/ci/module.f.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { utf8 } from "../text/module.f.js";
|
|
7
|
-
import {
|
|
7
|
+
import { fluent, pure } from "../types/effects/module.f.js";
|
|
8
8
|
import { writeFile } from "../types/effects/node/module.f.js";
|
|
9
9
|
const os = ['ubuntu', 'macos', 'windows'];
|
|
10
10
|
const architecture = ['intel', 'arm'];
|
|
@@ -177,5 +177,8 @@ const gha = {
|
|
|
177
177
|
on: { pull_request: {} },
|
|
178
178
|
jobs,
|
|
179
179
|
};
|
|
180
|
-
export const effect =
|
|
180
|
+
export const effect = fluent
|
|
181
|
+
.step(() => writeFile('.github/workflows/ci.yml', utf8(JSON.stringify(gha, null, ' '))))
|
|
182
|
+
.step(() => pure(0))
|
|
183
|
+
.effect;
|
|
181
184
|
export default () => effect;
|
package/dev/module.f.js
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { fromIo } from "../io/module.f.js";
|
|
7
7
|
import { updateVersion } from "./version/module.f.js";
|
|
8
|
-
import {
|
|
8
|
+
import { encodeUtf8 } from "../types/uint8array/module.f.js";
|
|
9
9
|
import { readFile } from "../types/effects/node/module.f.js";
|
|
10
10
|
import { utf8ToString } from "../text/module.f.js";
|
|
11
11
|
import { unwrap } from "../types/result/module.f.js";
|
|
12
|
-
import {
|
|
12
|
+
import { fluent, pure } from "../types/effects/module.f.js";
|
|
13
13
|
export const todo = () => { throw 'not implemented'; };
|
|
14
14
|
const cmp = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0;
|
|
15
15
|
export const env = ({ process: { env } }) => a => {
|
|
@@ -58,7 +58,11 @@ export const loadModuleMap = async (io) => {
|
|
|
58
58
|
return Object.fromEntries(map.toSorted(cmp));
|
|
59
59
|
};
|
|
60
60
|
const denoJson = './deno.json';
|
|
61
|
-
const index2 =
|
|
61
|
+
const index2 = fluent
|
|
62
|
+
.step(() => updateVersion)
|
|
63
|
+
.step(() => readFile(denoJson))
|
|
64
|
+
.step(v => pure(JSON.parse(utf8ToString(unwrap(v)))))
|
|
65
|
+
.effect;
|
|
62
66
|
export const index = async (io) => {
|
|
63
67
|
const runner = fromIo(io);
|
|
64
68
|
const jsr_json = await runner(index2);
|
package/dev/version/module.f.js
CHANGED
|
@@ -4,12 +4,15 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { utf8, utf8ToString } from "../../text/module.f.js";
|
|
7
|
-
import { all, fluent,
|
|
7
|
+
import { all, fluent, pure, step } from "../../types/effects/module.f.js";
|
|
8
8
|
import { readFile, writeFile } from "../../types/effects/node/module.f.js";
|
|
9
9
|
import { unwrap } from "../../types/result/module.f.js";
|
|
10
10
|
const { stringify, parse } = JSON;
|
|
11
11
|
const jsonFile = (jsonFile) => `${jsonFile}.json`;
|
|
12
|
-
const readJson = (name) =>
|
|
12
|
+
const readJson = (name) => fluent
|
|
13
|
+
.step(() => readFile(jsonFile(name)))
|
|
14
|
+
.step(v => pure(parse(utf8ToString(unwrap(v)))))
|
|
15
|
+
.effect;
|
|
13
16
|
const writeVersion = (version) => (name) => step(readJson(name))(json => writeFile(jsonFile(name), utf8(stringify({
|
|
14
17
|
...json,
|
|
15
18
|
version,
|
|
@@ -20,5 +23,5 @@ export const updateVersion = fluent
|
|
|
20
23
|
const w = writeVersion(p.version);
|
|
21
24
|
return all([w('package'), w('deno')]);
|
|
22
25
|
})
|
|
23
|
-
.
|
|
26
|
+
.step(() => pure(0))
|
|
24
27
|
.effect;
|
package/package.json
CHANGED
|
@@ -22,7 +22,6 @@ export declare const map: <O extends Operations, T>(e: Effect<O, T>) => <R>(f: (
|
|
|
22
22
|
export type Fluent<O extends Operations, T> = {
|
|
23
23
|
readonly effect: Effect<O, T>;
|
|
24
24
|
readonly step: <O1 extends Operations, R>(f: (_: T) => Effect<O1, R>) => Fluent<O | O1, R>;
|
|
25
|
-
readonly map: <R>(f: (_: T) => R) => Fluent<O, R>;
|
|
26
25
|
};
|
|
27
26
|
export declare const fluent: Fluent<{}, void>;
|
|
28
27
|
export declare const all: <O extends Operations, T>(set: readonly Effect<O, T>[]) => Effect<O, readonly T[]>;
|
package/website/module.f.js
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
import { htmlToString } from "../html/module.f.js";
|
|
7
7
|
import { writeFile } from "../types/effects/node/module.f.js";
|
|
8
8
|
import { utf8 } from "../text/module.f.js";
|
|
9
|
-
import { fluent } from "../types/effects/module.f.js";
|
|
9
|
+
import { fluent, pure } from "../types/effects/module.f.js";
|
|
10
10
|
const html = ['body',
|
|
11
11
|
['a', { href: 'https://github.com/functionalscript/functionalscript' }, 'GitHub Repository']
|
|
12
12
|
];
|
|
13
13
|
const program = fluent
|
|
14
14
|
.step(() => writeFile('index.html', utf8(htmlToString(html))))
|
|
15
|
-
.
|
|
15
|
+
.step(() => pure(0))
|
|
16
16
|
.effect;
|
|
17
17
|
export default () => program;
|