functionalscript 0.3.1 → 0.3.2

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.
@@ -27,12 +27,11 @@ jobs:
27
27
  - run: npm ci
28
28
  - run: npm run version
29
29
  - run: npm run index
30
- - run: npm run tscp
31
30
  - run: npm publish
32
31
  continue-on-error: true
33
32
  env:
34
33
  NODE_AUTH_TOKEN: ${{secrets.npm_token}}
35
- - run: deno publish --allow-dirty
34
+ - run: deno publish --allow-dirty --allow-slow-types
36
35
  continue-on-error: true
37
36
 
38
37
 
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalscript/functionalscript",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "license": "AGPL-3.0-only",
5
5
  "exports": {
6
6
  "./com/cpp": "./com/cpp/module.f.ts",
package/fsc/module.f.ts CHANGED
@@ -1,24 +1,27 @@
1
1
  import * as operator from '../types/function/operator/module.f.ts'
2
- import * as rangeMap from '../types/range_map/module.f.ts'
3
- const { merge: rangeMapMerge, fromRange, get } = rangeMap
2
+ import {
3
+ merge as rangeMapMerge,
4
+ fromRange,
5
+ get,
6
+ type RangeMapArray,
7
+ type RangeMerge,
8
+ } from '../types/range_map/module.f.ts'
4
9
  import * as list from '../types/list/module.f.ts'
5
10
  const { reduce: listReduce } = list
6
- import * as ascii from '../text/ascii/module.f.ts'
7
- const { range: asciiRange } = ascii
8
- const { fromCharCode } = String
9
- import * as f from '../types/function/module.f.ts'
10
- const { fn } = f
11
- import * as _range from '../types/range/module.f.ts'
12
- const { one } = _range
11
+ import { range as asciiRange } from '../text/ascii/module.f.ts'
12
+ import { fn } from '../types/function/module.f.ts'
13
+ import { one, type Range } from '../types/range/module.f.ts'
13
14
  const { toArray, map } = list
14
15
 
16
+ const fromCharCode = String.fromCharCode
17
+
15
18
  type Result = readonly[readonly string[], ToResult]
16
19
 
17
20
  type ToResult = (codePoint: number) => Result
18
21
 
19
22
  type CreateToResult<T> = (state: T) => ToResult
20
23
 
21
- type State<T> = rangeMap.RangeMapArray<CreateToResult<T>>
24
+ type State<T> = RangeMapArray<CreateToResult<T>>
22
25
 
23
26
  const unexpectedSymbol
24
27
  : ToResult
@@ -42,8 +45,8 @@ const empty
42
45
 
43
46
  const reduce = <T>(a: list.List<State<T>>): State<T> => {
44
47
  const merge
45
- : rangeMap.RangeMerge<CreateToResult<T>>
46
- = rangeMapMerge({
48
+ : RangeMerge<CreateToResult<T>>
49
+ = rangeMapMerge({
47
50
  union,
48
51
  equal: operator.strictEqual,
49
52
  })
@@ -55,13 +58,16 @@ const codePointRange = fromRange(def)
55
58
  const range = fn(asciiRange).then(codePointRange).result
56
59
 
57
60
  const rangeSet
58
- = (l: readonly string[]) => <T>(f: CreateToResult<T>): State<T> => {
61
+ = (l: readonly string[]) => <T>(f: CreateToResult<T>): State<T> => {
62
+
59
63
  const codePointRange
60
- : (a: _range.Range) => (f: CreateToResult<T>) => State<T>
61
- = fromRange(def)
64
+ : (a: Range) => (f: CreateToResult<T>) => State<T>
65
+ = fromRange(def)
66
+
62
67
  const g
63
- : (r: string) => State<T>
64
- = r => codePointRange(asciiRange(r))(f)
68
+ : (r: string) => State<T>
69
+ = r => codePointRange(asciiRange(r))(f)
70
+
65
71
  return reduce(map(g)(l))
66
72
  }
67
73
 
package/html/module.f.ts CHANGED
@@ -1,10 +1,7 @@
1
- import * as list from '../types/list/module.f.ts'
2
- const { map, flatMap, flat, concat: listConcat } = list
3
- import * as s from '../types/string/module.f.ts'
4
- const { concat: stringConcat } = s
1
+ import { map, flatMap, flat, concat as listConcat, type List } from '../types/list/module.f.ts'
2
+ import { concat as stringConcat } from '../types/string/module.f.ts'
5
3
  import * as O from '../types/object/module.f.ts'
6
- import * as f from '../types/function/module.f.ts'
7
- const { compose } = f
4
+ import { compose } from '../types/function/module.f.ts'
8
5
  import * as utf16 from '../text/utf16/module.f.ts'
9
6
  const { stringToList } = utf16
10
7
  const { fromCharCode } = String
@@ -72,33 +69,33 @@ const escapeCharCode
72
69
  const escape = compose(stringToList)(map(escapeCharCode))
73
70
 
74
71
  const node
75
- : (n: Node) => list.List<string>
76
- = n => typeof n === 'string' ? escape(n) : element(n)
72
+ : (n: Node) => List<string>
73
+ = n => typeof n === 'string' ? escape(n) : element(n)
77
74
 
78
75
  const nodes = flatMap(node)
79
76
 
80
77
  const attribute
81
- : (a: O.Entry<string>) => list.List<string>
82
- = ([name, value]) => flat([[' ', name, '="'], escape(value), ['"']])
78
+ : (a: O.Entry<string>) => List<string>
79
+ = ([name, value]) => flat([[' ', name, '="'], escape(value), ['"']])
83
80
 
84
81
  const attributes
85
- : (a: Attributes) => list.List<string>
86
- = compose(entries)(flatMap(attribute))
82
+ : (a: Attributes) => List<string>
83
+ = compose(entries)(flatMap(attribute))
87
84
 
88
85
  const open
89
- : (t: string) => (a: Attributes) => list.List<string>
90
- = t => a => flat([[`<`, t], attributes(a), [`>`]])
86
+ : (t: string) => (a: Attributes) => List<string>
87
+ = t => a => flat([[`<`, t], attributes(a), [`>`]])
91
88
 
92
89
  const element3
93
- : (t: string) => (an: readonly[Attributes, readonly Node[]]) => list.List<string>
94
- = t => ([a, n]) => {
90
+ : (t: string) => (an: readonly[Attributes, readonly Node[]]) => List<string>
91
+ = t => ([a, n]) => {
95
92
  const o = flat([[`<`, t], attributes(a), [`>`]])
96
93
  return isVoid(t) ? o : flat([o, nodes(n), ['</', t, '>']])
97
94
  }
98
95
 
99
96
  export const element
100
- : (element: Element) => list.List<string>
101
- = e => {
97
+ : (element: Element) => List<string>
98
+ = e => {
102
99
  const [t, a, ...n] = e
103
100
  return element3(t)(a === undefined ? [{}, []]: typeof a === 'object' && !(a instanceof Array) ? [a, n] : [{}, [a, ...n]])
104
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "description": "FunctionalScript is a functional subset of JavaScript",
6
6
  "scripts": {
@@ -1,10 +1,17 @@
1
- import * as list from '../../types/list/module.f.ts'
1
+ import {
2
+ map,
3
+ flat,
4
+ stateScan,
5
+ reduce,
6
+ flatMap,
7
+ empty,
8
+ type List,
9
+ type Result,
10
+ } from '../../types/list/module.f.ts'
2
11
  import * as operator from '../../types/function/operator/module.f.ts'
3
- import * as range from '../../types/range/module.f.ts'
4
- const { contains } = range
12
+ import { contains } from '../../types/range/module.f.ts'
5
13
  import * as f from '../../types/function/module.f.ts'
6
14
  const { fn } = f
7
- const { map, flat, stateScan, reduce, flatMap, empty } = list
8
15
 
9
16
  type WordOrEof = u16|null
10
17
 
@@ -36,8 +43,8 @@ const isSupplementaryPlane
36
43
  = contains([0x01_0000, 0x10_ffff])
37
44
 
38
45
  const codePointToUtf16
39
- : (input: i32) => list.List<u16>
40
- = codePoint => {
46
+ : (input: i32) => List<u16>
47
+ = codePoint => {
41
48
  if (isBmpCodePoint(codePoint)) { return [codePoint] }
42
49
  if (isSupplementaryPlane(codePoint)) {
43
50
  const n = codePoint - 0x1_0000
@@ -53,8 +60,8 @@ export const fromCodePointList = flatMap(codePointToUtf16)
53
60
  const u16 = contains([0x0000, 0xFFFF])
54
61
 
55
62
  const utf16ByteToCodePointOp
56
- : operator.StateScan<u16, Utf16State, list.List<i32>>
57
- = state => word => {
63
+ : operator.StateScan<u16, Utf16State, List<i32>>
64
+ = state => word => {
58
65
  if (!u16(word)) {
59
66
  return [[0xffffffff], state]
60
67
  }
@@ -74,27 +81,27 @@ const utf16ByteToCodePointOp
74
81
  }
75
82
 
76
83
  const utf16EofToCodePointOp
77
- : (state: Utf16State) => readonly[list.List<i32>, Utf16State]
78
- = state => [state === null ? empty : [state | errorMask], null]
84
+ : (state: Utf16State) => readonly[List<i32>, Utf16State]
85
+ = state => [state === null ? empty : [state | errorMask], null]
79
86
 
80
87
  const utf16ByteOrEofToCodePointOp
81
- : operator.StateScan<WordOrEof, Utf16State, list.List<i32>>
82
- = state => input => input === null ? utf16EofToCodePointOp(state) : utf16ByteToCodePointOp(state)(input)
88
+ : operator.StateScan<WordOrEof, Utf16State, List<i32>>
89
+ = state => input => input === null ? utf16EofToCodePointOp(state) : utf16ByteToCodePointOp(state)(input)
83
90
 
84
91
  const eofList
85
- : list.List<WordOrEof>
86
- = [null]
92
+ : List<WordOrEof>
93
+ = [null]
87
94
 
88
95
  export const toCodePointList
89
- : (input: list.List<u16>) => list.List<i32>
90
- = input => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
96
+ : (input: List<u16>) => List<i32>
97
+ = input => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
91
98
 
92
99
  export const stringToList
93
- : (s: string) => list.List<u16>
94
- = s => {
100
+ : (s: string) => List<u16>
101
+ = s => {
95
102
  const at
96
- : (i: number) => list.Result<number>
97
- = i => {
103
+ : (i: number) => Result<number>
104
+ = i => {
98
105
  const first = s.charCodeAt(i)
99
106
  return isNaN(first) ? empty : { first, tail: () => at(i + 1) }
100
107
  }
@@ -102,7 +109,7 @@ export const stringToList
102
109
  }
103
110
 
104
111
  export const listToString
105
- : (input: list.List<u16>) => string
106
- = fn(map(String.fromCharCode))
112
+ : (input: List<u16>) => string
113
+ = fn(map(String.fromCharCode))
107
114
  .then(reduce(operator.concat)(''))
108
115
  .result
@@ -1,7 +1,6 @@
1
- import * as list from '../../types/list/module.f.ts'
1
+ import { flatMap, flat, stateScan, type List } from '../../types/list/module.f.ts'
2
2
  import * as operator from '../../types/function/operator/module.f.ts'
3
3
  import * as Array from '../../types/array/module.f.ts'
4
- const { flatMap, flat, stateScan } = list
5
4
 
6
5
  type ByteOrEof = u8|null
7
6
 
@@ -16,7 +15,7 @@ type i32 = number
16
15
  const errorMask = 0b1000_0000_0000_0000_0000_0000_0000_0000
17
16
 
18
17
  const codePointToUtf8
19
- : (input:number) => list.List<u8>
18
+ : (input:number) => List<u8>
20
19
  = input => {
21
20
  if (input >= 0x0000 && input <= 0x007f) { return [input & 0b01111_1111] }
22
21
  if (input >= 0x0080 && input <= 0x07ff) { return [input >> 6 | 0b1100_0000, input & 0b0011_1111 | 0b1000_0000] }
@@ -61,7 +60,7 @@ const utf8StateToError
61
60
  }
62
61
 
63
62
  const utf8ByteToCodePointOp
64
- : operator.StateScan<number, Utf8State, list.List<i32>>
63
+ : operator.StateScan<number, Utf8State, List<i32>>
65
64
  = state => byte => {
66
65
  if (byte < 0x00 || byte > 0xff) {
67
66
  return [[errorMask], state]
@@ -98,18 +97,18 @@ const utf8ByteToCodePointOp
98
97
  }
99
98
 
100
99
  const utf8EofToCodePointOp
101
- : (state: Utf8State) => readonly[list.List<i32>, Utf8State]
102
- = state =>
100
+ : (state: Utf8State) => readonly[List<i32>, Utf8State]
101
+ = state =>
103
102
  [state === null ? null : [utf8StateToError(state)], null]
104
103
 
105
104
  const utf8ByteOrEofToCodePointOp
106
- : operator.StateScan<ByteOrEof, Utf8State, list.List<i32>>
107
- = state => input => input === null ? utf8EofToCodePointOp(state) : utf8ByteToCodePointOp(state)(input)
105
+ : operator.StateScan<ByteOrEof, Utf8State, List<i32>>
106
+ = state => input => input === null ? utf8EofToCodePointOp(state) : utf8ByteToCodePointOp(state)(input)
108
107
 
109
108
  const eofList
110
- : list.List<ByteOrEof>
111
- = [null]
109
+ : List<ByteOrEof>
110
+ = [null]
112
111
 
113
112
  export const toCodePointList
114
- : (input: list.List<u8>) => list.List<i32>
115
- = input => flat(stateScan(utf8ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
113
+ : (input: List<u8>) => List<i32>
114
+ = input => flat(stateScan(utf8ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
@@ -1,8 +1,7 @@
1
1
  import * as compare from '../function/compare/module.f.ts'
2
2
  import * as Operator from '../function/operator/module.f.ts'
3
3
  const { unsafeCmp } = compare
4
- import * as list from '../list/module.f.ts'
5
- const { reduce } = list
4
+ import { reduce } from '../list/module.f.ts'
6
5
 
7
6
  type Unary = Operator.Unary<bigint, bigint>
8
7
 
@@ -1,5 +1,4 @@
1
- import * as f from '../function/module.f.ts'
2
- const { compose } = f
1
+ import { compose } from '../function/module.f.ts'
3
2
  import * as RangeMap from '../range_map/module.f.ts'
4
3
  import * as SortedSet from '../sorted_set/module.f.ts'
5
4
  import * as list from '../list/module.f.ts'
@@ -1,14 +1,17 @@
1
- import * as function_ from '../function/module.f.ts'
2
- const { identity, fn, compose } = function_
3
- import * as operator from '../function/operator/module.f.ts'
4
- const {
1
+ import { identity, fn, compose } from '../function/module.f.ts'
2
+ import {
5
3
  addition,
6
4
  logicalNot,
7
5
  strictEqual,
8
6
  stateScanToScan,
9
7
  foldToScan,
10
- reduceToScan
11
- } = operator
8
+ reduceToScan,
9
+ type Scan,
10
+ type StateScan,
11
+ type Fold,
12
+ type Reduce,
13
+ type Equal,
14
+ } from '../function/operator/module.f.ts'
12
15
 
13
16
  export type List<T> = NotLazy<T> | Thunk<T>
14
17
 
@@ -248,30 +251,30 @@ export const cycle
248
251
  }
249
252
 
250
253
  const scanStep
251
- : <I, O>(op: operator.Scan<I, O>) => (ne: NonEmpty<I>) => List<O>
254
+ : <I, O>(op: Scan<I, O>) => (ne: NonEmpty<I>) => List<O>
252
255
  = op => ne => {
253
256
  const [first, newOp] = op(ne.first)
254
257
  return { first, tail: scan(newOp)(ne.tail) }
255
258
  }
256
259
 
257
260
  export const scan
258
- : <I, O>(op: operator.Scan<I, O>) => (input: List<I>) => Thunk<O>
261
+ : <I, O>(op: Scan<I, O>) => (input: List<I>) => Thunk<O>
259
262
  = op => apply(scanStep(op))
260
263
 
261
264
  export const stateScan
262
- : <I, S, O>(op: operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>
265
+ : <I, S, O>(op: StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>
263
266
  = op => compose(stateScanToScan(op))(scan)
264
267
 
265
268
  export const foldScan
266
- : <I,O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>
269
+ : <I,O>(op: Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>
267
270
  = op => compose(foldToScan(op))(scan)
268
271
 
269
272
  export const fold
270
- : <I,O>(op: operator.Fold<I, O>) => (init: O) => (input: List<I>) => O
273
+ : <I,O>(op: Fold<I, O>) => (init: O) => (input: List<I>) => O
271
274
  = op => init => compose(foldScan(op)(init))(last(init))
272
275
 
273
276
  export const reduce
274
- : <T>(op: operator.Reduce<T>) => <D>(def: D) => (input: List<T>) => D|T
277
+ : <T>(op: Reduce<T>) => <D>(def: D) => (input: List<T>) => D|T
275
278
  = op => def => compose(scan(reduceToScan(op)))(last(def))
276
279
 
277
280
  const lengthList
@@ -304,7 +307,7 @@ export const entries
304
307
  = input => {
305
308
  type T = typeof input extends List<infer T> ? T : never
306
309
  const o
307
- : operator.StateScan<T, number, Entry<T>>
310
+ : StateScan<T, number, Entry<T>>
308
311
  = entryOperator
309
312
  return stateScan(o)(0)(input)
310
313
  }
@@ -328,9 +331,9 @@ export const zip
328
331
  }
329
332
 
330
333
  export const equal
331
- : <T>(e: operator.Equal<T>) => (a: List<T>) => (b: List<T>) => boolean
334
+ : <T>(e: Equal<T>) => (a: List<T>) => (b: List<T>) => boolean
332
335
  = e => {
333
- type T = typeof e extends operator.Equal<infer T> ? T : never
336
+ type T = typeof e extends Equal<infer T> ? T : never
334
337
  const f
335
338
  : (a: List<T>) => (b: List<T>) => List<boolean>
336
339
  = a => b => () => {
@@ -1,7 +1,5 @@
1
- import * as list from '../list/module.f.ts'
2
- const { reduce } = list
3
- import * as operator from '../function/operator/module.f.ts'
4
- const { addition, min: minOp, max: maxOp } = operator
1
+ import { reduce } from '../list/module.f.ts'
2
+ import { addition, min as minOp, max as maxOp } from '../function/operator/module.f.ts'
5
3
  import * as compare from '../function/compare/module.f.ts'
6
4
  const { unsafeCmp } = compare
7
5
 
@@ -1,14 +1,12 @@
1
1
  import * as list from '../list/module.f.ts'
2
2
  const { reduce: listReduce, repeat: listRepeat } = list
3
- import * as f from '../function/module.f.ts'
4
- const { compose } = f
3
+ import { compose } from '../function/module.f.ts'
5
4
  import * as compare from '../function/compare/module.f.ts'
6
5
  const { unsafeCmp } = compare
7
- import * as op from '../function/operator/module.f.ts'
8
- const { join: joinOp, concat: concatOp } = op
6
+ import { join as joinOp, concat as concatOp, type Reduce } from '../function/operator/module.f.ts'
9
7
 
10
8
  const reduce
11
- : (o: op.Reduce<string>) => (input: list.List<string>) => string
9
+ : (o: Reduce<string>) => (input: list.List<string>) => string
12
10
  = o => listReduce(o)('')
13
11
 
14
12
  export const join = compose(joinOp)(reduce)
@@ -6,17 +6,15 @@ import * as btr from '../btree/remove/module.f.ts'
6
6
  const { remove: btreeRemove } = btr
7
7
  import * as bts from '../btree/set/module.f.ts'
8
8
  const { set: btreeSet } = bts
9
- export const {
10
- values,
11
- empty,
12
- }: { values: (s: StringSet) => list.List<string>, empty: null } = btree
13
9
  import * as string from "../string/module.f.ts"
14
10
  const { cmp } = string
15
- import * as list from '../list/module.f.ts'
16
- const { fold } = list
11
+ import { fold, type List } from '../list/module.f.ts'
17
12
  import * as f from '../function/module.f.ts'
18
13
  const { compose } = f
19
14
 
15
+ export const values: (s: StringSet) => List<string> = btree.values
16
+ export const empty: null = btree.empty
17
+
20
18
  export type StringSet = BtreeTypes.Tree<string>
21
19
 
22
20
  export const contains