functionalscript 0.3.1 → 0.3.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/.github/workflows/npm-publish.yml +1 -2
- package/crypto/sha2/module.f.ts +6 -2
- package/deno.json +1 -1
- package/dev/module.f.ts +1 -1
- package/fsc/module.f.ts +26 -18
- package/html/module.f.ts +21 -20
- package/json/serializer/module.f.ts +6 -2
- package/package.json +1 -1
- package/text/sgr/module.f.ts +0 -4
- package/text/utf16/module.f.ts +36 -24
- package/text/utf8/module.f.ts +14 -13
- package/types/bigint/module.f.ts +4 -3
- package/types/byte_set/module.f.ts +9 -6
- package/types/function/operator/module.f.ts +3 -1
- package/types/list/module.f.ts +21 -16
- package/types/number/module.f.ts +13 -9
- package/types/string/module.f.ts +14 -12
- package/types/string_set/module.f.ts +9 -9
|
@@ -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/crypto/sha2/module.f.ts
CHANGED
|
@@ -206,6 +206,10 @@ export const computeSha224
|
|
|
206
206
|
: (input: readonly number[]) => (bitsCount: number) => Hash8
|
|
207
207
|
= compute(init224)
|
|
208
208
|
|
|
209
|
-
export const compress256
|
|
209
|
+
export const compress256
|
|
210
|
+
: (data: Array16) => Hash8
|
|
211
|
+
= compress(init256)
|
|
210
212
|
|
|
211
|
-
export const compress224
|
|
213
|
+
export const compress224
|
|
214
|
+
: (data: Array16) => Hash8
|
|
215
|
+
= compress(init224)
|
package/deno.json
CHANGED
package/dev/module.f.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const todo = () => { throw 'not implemented' }
|
|
1
|
+
export const todo = (): never => { throw 'not implemented' }
|
package/fsc/module.f.ts
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import * as operator from '../types/function/operator/module.f.ts'
|
|
2
|
-
import
|
|
3
|
-
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
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> =
|
|
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
|
-
|
|
46
|
-
|
|
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
|
-
|
|
61
|
+
= (l: readonly string[]) => <T>(f: CreateToResult<T>): State<T> => {
|
|
62
|
+
|
|
59
63
|
const codePointRange
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
: (a: Range) => (f: CreateToResult<T>) => State<T>
|
|
65
|
+
= fromRange(def)
|
|
66
|
+
|
|
62
67
|
const g
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
: (r: string) => State<T>
|
|
69
|
+
= r => codePointRange(asciiRange(r))(f)
|
|
70
|
+
|
|
65
71
|
return reduce(map(g)(l))
|
|
66
72
|
}
|
|
67
73
|
|
|
@@ -79,7 +85,9 @@ const toInit
|
|
|
79
85
|
: () => ToResult
|
|
80
86
|
= () => () => [[], init]
|
|
81
87
|
|
|
82
|
-
export const init
|
|
88
|
+
export const init
|
|
89
|
+
: ToResult
|
|
90
|
+
= create([
|
|
83
91
|
codePointRange(one(terminal))(toInit),
|
|
84
92
|
rangeSet(['\t', ' ', '\n', '\r'])(toInit),
|
|
85
93
|
range('!')(() => () => [['!'], unexpectedSymbol]),
|
package/html/module.f.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
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
|
|
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,37 +69,41 @@ const escapeCharCode
|
|
|
72
69
|
const escape = compose(stringToList)(map(escapeCharCode))
|
|
73
70
|
|
|
74
71
|
const node
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
82
|
-
|
|
78
|
+
: (a: O.Entry<string>) => List<string>
|
|
79
|
+
= ([name, value]) => flat([[' ', name, '="'], escape(value), ['"']])
|
|
83
80
|
|
|
84
81
|
const attributes
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
: (a: Attributes) => List<string>
|
|
83
|
+
= compose(entries)(flatMap(attribute))
|
|
87
84
|
|
|
88
85
|
const open
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
: (t: string) => (a: Attributes) => List<string>
|
|
87
|
+
= t => a => flat([[`<`, t], attributes(a), [`>`]])
|
|
91
88
|
|
|
92
89
|
const element3
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
101
|
-
|
|
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
|
}
|
|
105
102
|
|
|
106
|
-
export const html
|
|
103
|
+
export const html
|
|
104
|
+
: (_: Element) => List<string>
|
|
105
|
+
= compose(element)(listConcat(['<!DOCTYPE html>']))
|
|
107
106
|
|
|
108
|
-
export const htmlToString
|
|
107
|
+
export const htmlToString
|
|
108
|
+
: (_: Element) => string
|
|
109
|
+
= compose(html)(stringConcat)
|
|
@@ -59,9 +59,13 @@ const wrap
|
|
|
59
59
|
return input => flat([seqOpen, join(input), seqClose])
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
export const objectWrap
|
|
62
|
+
export const objectWrap
|
|
63
|
+
: (input: list.List<list.List<string>>) => list.List<string>
|
|
64
|
+
= wrap('{')('}')
|
|
63
65
|
|
|
64
|
-
export const arrayWrap
|
|
66
|
+
export const arrayWrap
|
|
67
|
+
: (input: list.List<list.List<string>>) => list.List<string>
|
|
68
|
+
= wrap('[')(']')
|
|
65
69
|
|
|
66
70
|
type Entry<T> = O.Entry<Unknown<T>>
|
|
67
71
|
|
package/package.json
CHANGED
package/text/sgr/module.f.ts
CHANGED
package/text/utf16/module.f.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
map,
|
|
3
|
+
flat,
|
|
4
|
+
stateScan,
|
|
5
|
+
reduce,
|
|
6
|
+
flatMap,
|
|
7
|
+
empty,
|
|
8
|
+
type List,
|
|
9
|
+
type Result,
|
|
10
|
+
type Thunk,
|
|
11
|
+
} from '../../types/list/module.f.ts'
|
|
2
12
|
import * as operator from '../../types/function/operator/module.f.ts'
|
|
3
|
-
import
|
|
4
|
-
const { contains } = range
|
|
13
|
+
import { contains } from '../../types/range/module.f.ts'
|
|
5
14
|
import * as f from '../../types/function/module.f.ts'
|
|
6
15
|
const { fn } = f
|
|
7
|
-
const { map, flat, stateScan, reduce, flatMap, empty } = list
|
|
8
16
|
|
|
9
17
|
type WordOrEof = u16|null
|
|
10
18
|
|
|
@@ -36,8 +44,8 @@ const isSupplementaryPlane
|
|
|
36
44
|
= contains([0x01_0000, 0x10_ffff])
|
|
37
45
|
|
|
38
46
|
const codePointToUtf16
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
: (input: i32) => List<u16>
|
|
48
|
+
= codePoint => {
|
|
41
49
|
if (isBmpCodePoint(codePoint)) { return [codePoint] }
|
|
42
50
|
if (isSupplementaryPlane(codePoint)) {
|
|
43
51
|
const n = codePoint - 0x1_0000
|
|
@@ -48,13 +56,17 @@ const codePointToUtf16
|
|
|
48
56
|
return [codePoint & 0xffff]
|
|
49
57
|
}
|
|
50
58
|
|
|
51
|
-
export const fromCodePointList
|
|
59
|
+
export const fromCodePointList
|
|
60
|
+
: (input: List<number>) => Thunk<number>
|
|
61
|
+
= flatMap(codePointToUtf16)
|
|
52
62
|
|
|
53
|
-
const u16
|
|
63
|
+
const u16
|
|
64
|
+
: (i: number) => boolean
|
|
65
|
+
= contains([0x0000, 0xFFFF])
|
|
54
66
|
|
|
55
67
|
const utf16ByteToCodePointOp
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
: operator.StateScan<u16, Utf16State, List<i32>>
|
|
69
|
+
= state => word => {
|
|
58
70
|
if (!u16(word)) {
|
|
59
71
|
return [[0xffffffff], state]
|
|
60
72
|
}
|
|
@@ -74,27 +86,27 @@ const utf16ByteToCodePointOp
|
|
|
74
86
|
}
|
|
75
87
|
|
|
76
88
|
const utf16EofToCodePointOp
|
|
77
|
-
|
|
78
|
-
|
|
89
|
+
: (state: Utf16State) => readonly[List<i32>, Utf16State]
|
|
90
|
+
= state => [state === null ? empty : [state | errorMask], null]
|
|
79
91
|
|
|
80
92
|
const utf16ByteOrEofToCodePointOp
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
: operator.StateScan<WordOrEof, Utf16State, List<i32>>
|
|
94
|
+
= state => input => input === null ? utf16EofToCodePointOp(state) : utf16ByteToCodePointOp(state)(input)
|
|
83
95
|
|
|
84
96
|
const eofList
|
|
85
|
-
|
|
86
|
-
|
|
97
|
+
: List<WordOrEof>
|
|
98
|
+
= [null]
|
|
87
99
|
|
|
88
100
|
export const toCodePointList
|
|
89
|
-
|
|
90
|
-
|
|
101
|
+
: (input: List<u16>) => List<i32>
|
|
102
|
+
= input => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
|
|
91
103
|
|
|
92
104
|
export const stringToList
|
|
93
|
-
|
|
94
|
-
|
|
105
|
+
: (s: string) => List<u16>
|
|
106
|
+
= s => {
|
|
95
107
|
const at
|
|
96
|
-
|
|
97
|
-
|
|
108
|
+
: (i: number) => Result<number>
|
|
109
|
+
= i => {
|
|
98
110
|
const first = s.charCodeAt(i)
|
|
99
111
|
return isNaN(first) ? empty : { first, tail: () => at(i + 1) }
|
|
100
112
|
}
|
|
@@ -102,7 +114,7 @@ export const stringToList
|
|
|
102
114
|
}
|
|
103
115
|
|
|
104
116
|
export const listToString
|
|
105
|
-
|
|
106
|
-
|
|
117
|
+
: (input: List<u16>) => string
|
|
118
|
+
= fn(map(String.fromCharCode))
|
|
107
119
|
.then(reduce(operator.concat)(''))
|
|
108
120
|
.result
|
package/text/utf8/module.f.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { flatMap, flat, stateScan, type List, type Thunk } 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) =>
|
|
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] }
|
|
@@ -31,7 +30,9 @@ const codePointToUtf8
|
|
|
31
30
|
return [errorMask]
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
export const fromCodePointList
|
|
33
|
+
export const fromCodePointList
|
|
34
|
+
: (input: List<number>) => Thunk<number>
|
|
35
|
+
= flatMap(codePointToUtf8)
|
|
35
36
|
|
|
36
37
|
const utf8StateToError
|
|
37
38
|
: (state: Utf8NonEmptyState) => i32
|
|
@@ -61,7 +62,7 @@ const utf8StateToError
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
const utf8ByteToCodePointOp
|
|
64
|
-
: operator.StateScan<number, Utf8State,
|
|
65
|
+
: operator.StateScan<number, Utf8State, List<i32>>
|
|
65
66
|
= state => byte => {
|
|
66
67
|
if (byte < 0x00 || byte > 0xff) {
|
|
67
68
|
return [[errorMask], state]
|
|
@@ -98,18 +99,18 @@ const utf8ByteToCodePointOp
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
const utf8EofToCodePointOp
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
: (state: Utf8State) => readonly[List<i32>, Utf8State]
|
|
103
|
+
= state =>
|
|
103
104
|
[state === null ? null : [utf8StateToError(state)], null]
|
|
104
105
|
|
|
105
106
|
const utf8ByteOrEofToCodePointOp
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
: operator.StateScan<ByteOrEof, Utf8State, List<i32>>
|
|
108
|
+
= state => input => input === null ? utf8EofToCodePointOp(state) : utf8ByteToCodePointOp(state)(input)
|
|
108
109
|
|
|
109
110
|
const eofList
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
: List<ByteOrEof>
|
|
112
|
+
= [null]
|
|
112
113
|
|
|
113
114
|
export const toCodePointList
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
: (input: List<u8>) => List<i32>
|
|
116
|
+
= input => flat(stateScan(utf8ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
|
package/types/bigint/module.f.ts
CHANGED
|
@@ -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
|
|
5
|
-
const { reduce } = list
|
|
4
|
+
import { reduce, type List } from '../list/module.f.ts'
|
|
6
5
|
|
|
7
6
|
type Unary = Operator.Unary<bigint, bigint>
|
|
8
7
|
|
|
@@ -10,7 +9,9 @@ export const addition
|
|
|
10
9
|
: (a: bigint) => (b: bigint) => bigint
|
|
11
10
|
= a => b => a + b
|
|
12
11
|
|
|
13
|
-
export const sum
|
|
12
|
+
export const sum
|
|
13
|
+
: (input: List<bigint>) => bigint
|
|
14
|
+
= reduce(addition)(0n)
|
|
14
15
|
|
|
15
16
|
export const abs
|
|
16
17
|
: (a: bigint) => bigint
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
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'
|
|
@@ -47,13 +46,17 @@ const difference
|
|
|
47
46
|
|
|
48
47
|
// additional operations
|
|
49
48
|
|
|
50
|
-
export const set
|
|
49
|
+
export const set
|
|
50
|
+
: (_: number) => (b: ByteSet) => ByteSet
|
|
51
|
+
= compose(one)(union)
|
|
51
52
|
|
|
52
|
-
export const setRange
|
|
53
|
+
export const setRange
|
|
54
|
+
: (_: readonly [number, number]) => (b: ByteSet) => ByteSet
|
|
55
|
+
= compose(range)(union)
|
|
53
56
|
|
|
54
57
|
export const unset
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
: (n: Byte) => (s: ByteSet) => ByteSet
|
|
59
|
+
= n => s => difference(s)(one(n))
|
|
57
60
|
|
|
58
61
|
const counter = reverse(countdown(256))
|
|
59
62
|
|
package/types/list/module.f.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -219,7 +222,9 @@ export const isEmpty
|
|
|
219
222
|
.then(logicalNot)
|
|
220
223
|
.result
|
|
221
224
|
|
|
222
|
-
export const every
|
|
225
|
+
export const every
|
|
226
|
+
: (_: List<boolean>) => boolean
|
|
227
|
+
= fn(map(logicalNot))
|
|
223
228
|
.then(some)
|
|
224
229
|
.then(logicalNot)
|
|
225
230
|
.result
|
|
@@ -248,30 +253,30 @@ export const cycle
|
|
|
248
253
|
}
|
|
249
254
|
|
|
250
255
|
const scanStep
|
|
251
|
-
: <I, O>(op:
|
|
256
|
+
: <I, O>(op: Scan<I, O>) => (ne: NonEmpty<I>) => List<O>
|
|
252
257
|
= op => ne => {
|
|
253
258
|
const [first, newOp] = op(ne.first)
|
|
254
259
|
return { first, tail: scan(newOp)(ne.tail) }
|
|
255
260
|
}
|
|
256
261
|
|
|
257
262
|
export const scan
|
|
258
|
-
: <I, O>(op:
|
|
263
|
+
: <I, O>(op: Scan<I, O>) => (input: List<I>) => Thunk<O>
|
|
259
264
|
= op => apply(scanStep(op))
|
|
260
265
|
|
|
261
266
|
export const stateScan
|
|
262
|
-
: <I, S, O>(op:
|
|
267
|
+
: <I, S, O>(op: StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>
|
|
263
268
|
= op => compose(stateScanToScan(op))(scan)
|
|
264
269
|
|
|
265
270
|
export const foldScan
|
|
266
|
-
: <I,O>(op:
|
|
271
|
+
: <I,O>(op: Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>
|
|
267
272
|
= op => compose(foldToScan(op))(scan)
|
|
268
273
|
|
|
269
274
|
export const fold
|
|
270
|
-
: <I,O>(op:
|
|
275
|
+
: <I,O>(op: Fold<I, O>) => (init: O) => (input: List<I>) => O
|
|
271
276
|
= op => init => compose(foldScan(op)(init))(last(init))
|
|
272
277
|
|
|
273
278
|
export const reduce
|
|
274
|
-
: <T>(op:
|
|
279
|
+
: <T>(op: Reduce<T>) => <D>(def: D) => (input: List<T>) => D|T
|
|
275
280
|
= op => def => compose(scan(reduceToScan(op)))(last(def))
|
|
276
281
|
|
|
277
282
|
const lengthList
|
|
@@ -304,7 +309,7 @@ export const entries
|
|
|
304
309
|
= input => {
|
|
305
310
|
type T = typeof input extends List<infer T> ? T : never
|
|
306
311
|
const o
|
|
307
|
-
:
|
|
312
|
+
: StateScan<T, number, Entry<T>>
|
|
308
313
|
= entryOperator
|
|
309
314
|
return stateScan(o)(0)(input)
|
|
310
315
|
}
|
|
@@ -328,9 +333,9 @@ export const zip
|
|
|
328
333
|
}
|
|
329
334
|
|
|
330
335
|
export const equal
|
|
331
|
-
: <T>(e:
|
|
336
|
+
: <T>(e: Equal<T>) => (a: List<T>) => (b: List<T>) => boolean
|
|
332
337
|
= e => {
|
|
333
|
-
type T = typeof e extends
|
|
338
|
+
type T = typeof e extends Equal<infer T> ? T : never
|
|
334
339
|
const f
|
|
335
340
|
: (a: List<T>) => (b: List<T>) => List<boolean>
|
|
336
341
|
= a => b => () => {
|
package/types/number/module.f.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import * as operator from '../function/operator/module.f.ts'
|
|
4
|
-
const { addition, min: minOp, max: maxOp } = operator
|
|
1
|
+
import { reduce, type List } 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
|
|
|
8
|
-
export const sum
|
|
6
|
+
export const sum
|
|
7
|
+
: (input: List<number>) => number
|
|
8
|
+
= reduce(addition)(0)
|
|
9
9
|
|
|
10
|
-
export const min
|
|
10
|
+
export const min
|
|
11
|
+
: (input: List<number>) => number | null
|
|
12
|
+
= reduce(minOp)(null)
|
|
11
13
|
|
|
12
|
-
export const max
|
|
14
|
+
export const max
|
|
15
|
+
: (input: List<number>) => number | null
|
|
16
|
+
= reduce(maxOp)(null)
|
|
13
17
|
|
|
14
18
|
export const cmp
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
: (a: number) => (b: number) => compare.Sign
|
|
20
|
+
= unsafeCmp
|
package/types/string/module.f.ts
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import * as list from '../list/module.f.ts'
|
|
2
2
|
const { reduce: listReduce, repeat: listRepeat } = list
|
|
3
|
-
import
|
|
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
|
|
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
|
-
|
|
12
|
-
|
|
9
|
+
: (o: Reduce<string>) => (input: list.List<string>) => string
|
|
10
|
+
= o => listReduce(o)('')
|
|
13
11
|
|
|
14
|
-
export const join
|
|
12
|
+
export const join
|
|
13
|
+
: (_: string) => (input: list.List<string>) => string
|
|
14
|
+
= compose(joinOp)(reduce)
|
|
15
15
|
|
|
16
|
-
export const concat
|
|
16
|
+
export const concat
|
|
17
|
+
: (input: list.List<string>) => string
|
|
18
|
+
= reduce(concatOp)
|
|
17
19
|
|
|
18
20
|
export const repeat
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
: (n: string) => (v: number) => string
|
|
22
|
+
= v => compose(listRepeat(v))(concat)
|
|
21
23
|
|
|
22
24
|
export const cmp
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
: (a: string) => (b: string) => compare.Sign
|
|
26
|
+
= unsafeCmp
|
|
@@ -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
|
|
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
|
|
@@ -30,8 +28,10 @@ export const set
|
|
|
30
28
|
: (value: string) => (s: StringSet) => StringSet
|
|
31
29
|
= value => btreeSet(cmp(value))(() => value)
|
|
32
30
|
|
|
33
|
-
export const fromValues
|
|
31
|
+
export const fromValues
|
|
32
|
+
: (input: List<string>) => StringSet
|
|
33
|
+
= fold(set)(null)
|
|
34
34
|
|
|
35
35
|
export const remove
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
: (value: string) => (s: StringSet) => StringSet
|
|
37
|
+
= compose(cmp)(btreeRemove)
|