functionalscript 0.0.395 → 0.0.396

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.
@@ -66,7 +66,7 @@ const paramList = compose(entries)(filterParam)
66
66
  const result = v => f => fa => {
67
67
  const type = fa._
68
68
  return type === undefined ? v : f(type)
69
- }
69
+ }
70
70
 
71
71
  module.exports = {
72
72
  /** @readonly */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.395",
3
+ "version": "0.0.396",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {
package/test.f.cjs CHANGED
@@ -14,6 +14,7 @@ require('./commonjs/test.cjs')
14
14
  require('./commonjs/package/dependencies/test.f.cjs')
15
15
  require('./commonjs/package/test.f.cjs')
16
16
  require('./commonjs/path/test.f.cjs')
17
+ require('./types/function/test.f.cjs')
17
18
  require('./types/function/compare/test.f.cjs')
18
19
  require('./types/string_set/test.f.cjs')
19
20
  require('./types/option/test.f.cjs')
@@ -17,6 +17,20 @@ const identity = value => value
17
17
  /** @type {<A, B, C>(f: (a: A) => (b: B) => C) => (b: B) => (a: A) => C} */
18
18
  const flip = f => b => a => f(a)(b)
19
19
 
20
+ /**
21
+ * @template I,O
22
+ * @typedef {{
23
+ * readonly result: Func<I, O>
24
+ * readonly then: <T>(g: Func<O, T>) => Fn<I, T>
25
+ * }} Fn
26
+ */
27
+
28
+ /** @type {<I, O>(f: (i: I) => O) => Fn<I, O>} */
29
+ const fn = result => ({
30
+ result,
31
+ then: g => fn(compose(result)(g))
32
+ })
33
+
20
34
  module.exports = {
21
35
  /** @readonly */
22
36
  compare: require('./compare/module.f.cjs'),
@@ -28,4 +42,6 @@ module.exports = {
28
42
  compose,
29
43
  /** @readonly */
30
44
  flip,
45
+ /** @readonly */
46
+ fn,
31
47
  }
@@ -0,0 +1,17 @@
1
+ const { fn } = require('./module.f.cjs')
2
+
3
+ {
4
+ /** @type {(x: string) => readonly[string]} */
5
+ const f = x => [x]
6
+ /** @type {(x: readonly[string]) => readonly[number]} */
7
+ const g = ([x]) => [x.length]
8
+ /** @type {(x: readonly[number]) => number} */
9
+ const w = ([x]) => x
10
+
11
+ const r = fn(f).then(g).then(w).result
12
+
13
+ const result = r('hello')
14
+ if (result !== 5) { throw r }
15
+ }
16
+
17
+ module.exports = {}
@@ -1,9 +1,9 @@
1
1
  const btTypes = require('../btree/types/module.f.cjs')
2
2
  const btree = require('../btree/module.f.cjs')
3
- const {
3
+ const {
4
4
  find: { find, isFound },
5
- remove: { remove: btreeRemove },
6
- set: { set: btreeSet },
5
+ remove: { remove: btreeRemove },
6
+ set: { set: btreeSet },
7
7
  /** @type {(s: StringSet) => list.List<string>} */
8
8
  values,
9
9
  } = btree