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.
@@ -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
 
@@ -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 = compress(init256)
209
+ export const compress256
210
+ : (data: Array16) => Hash8
211
+ = compress(init256)
210
212
 
211
- export const compress224 = compress(init224)
213
+ export const compress224
214
+ : (data: Array16) => Hash8
215
+ = compress(init224)
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalscript/functionalscript",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "license": "AGPL-3.0-only",
5
5
  "exports": {
6
6
  "./com/cpp": "./com/cpp/module.f.ts",
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 * 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
 
@@ -79,7 +85,9 @@ const toInit
79
85
  : () => ToResult
80
86
  = () => () => [[], init]
81
87
 
82
- export const init = create([
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 * 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,37 +69,41 @@ 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
  }
105
102
 
106
- export const html = compose(element)(listConcat(['<!DOCTYPE html>']))
103
+ export const html
104
+ : (_: Element) => List<string>
105
+ = compose(element)(listConcat(['<!DOCTYPE html>']))
107
106
 
108
- export const htmlToString = compose(html)(stringConcat)
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 = wrap('{')('}')
62
+ export const objectWrap
63
+ : (input: list.List<list.List<string>>) => list.List<string>
64
+ = wrap('{')('}')
63
65
 
64
- export const arrayWrap = wrap('[')(']')
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "description": "FunctionalScript is a functional subset of JavaScript",
6
6
  "scripts": {
@@ -6,12 +6,8 @@ export const sgr
6
6
  = c => `\x1b[${c.toString()}m`
7
7
 
8
8
  export const codes = {
9
- /** @readonly */
10
9
  reset: sgr(0),
11
- /** @readonly */
12
10
  bold: sgr(1),
13
- /** @readonly */
14
11
  fgRed: sgr(31),
15
- /** @readonly */
16
12
  fgGreen: sgr(32),
17
13
  }
@@ -1,10 +1,18 @@
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
+ type Thunk,
11
+ } from '../../types/list/module.f.ts'
2
12
  import * as operator from '../../types/function/operator/module.f.ts'
3
- import * as range from '../../types/range/module.f.ts'
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
- : (input: i32) => list.List<u16>
40
- = codePoint => {
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 = flatMap(codePointToUtf16)
59
+ export const fromCodePointList
60
+ : (input: List<number>) => Thunk<number>
61
+ = flatMap(codePointToUtf16)
52
62
 
53
- const u16 = contains([0x0000, 0xFFFF])
63
+ const u16
64
+ : (i: number) => boolean
65
+ = contains([0x0000, 0xFFFF])
54
66
 
55
67
  const utf16ByteToCodePointOp
56
- : operator.StateScan<u16, Utf16State, list.List<i32>>
57
- = state => word => {
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
- : (state: Utf16State) => readonly[list.List<i32>, Utf16State]
78
- = state => [state === null ? empty : [state | errorMask], null]
89
+ : (state: Utf16State) => readonly[List<i32>, Utf16State]
90
+ = state => [state === null ? empty : [state | errorMask], null]
79
91
 
80
92
  const utf16ByteOrEofToCodePointOp
81
- : operator.StateScan<WordOrEof, Utf16State, list.List<i32>>
82
- = state => input => input === null ? utf16EofToCodePointOp(state) : utf16ByteToCodePointOp(state)(input)
93
+ : operator.StateScan<WordOrEof, Utf16State, List<i32>>
94
+ = state => input => input === null ? utf16EofToCodePointOp(state) : utf16ByteToCodePointOp(state)(input)
83
95
 
84
96
  const eofList
85
- : list.List<WordOrEof>
86
- = [null]
97
+ : List<WordOrEof>
98
+ = [null]
87
99
 
88
100
  export const toCodePointList
89
- : (input: list.List<u16>) => list.List<i32>
90
- = input => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
101
+ : (input: List<u16>) => List<i32>
102
+ = input => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
91
103
 
92
104
  export const stringToList
93
- : (s: string) => list.List<u16>
94
- = s => {
105
+ : (s: string) => List<u16>
106
+ = s => {
95
107
  const at
96
- : (i: number) => list.Result<number>
97
- = i => {
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
- : (input: list.List<u16>) => string
106
- = fn(map(String.fromCharCode))
117
+ : (input: List<u16>) => string
118
+ = fn(map(String.fromCharCode))
107
119
  .then(reduce(operator.concat)(''))
108
120
  .result
@@ -1,7 +1,6 @@
1
- import * as list from '../../types/list/module.f.ts'
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) => 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] }
@@ -31,7 +30,9 @@ const codePointToUtf8
31
30
  return [errorMask]
32
31
  }
33
32
 
34
- export const fromCodePointList = flatMap(codePointToUtf8)
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, list.List<i32>>
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
- : (state: Utf8State) => readonly[list.List<i32>, Utf8State]
102
- = state =>
102
+ : (state: Utf8State) => readonly[List<i32>, Utf8State]
103
+ = state =>
103
104
  [state === null ? null : [utf8StateToError(state)], null]
104
105
 
105
106
  const utf8ByteOrEofToCodePointOp
106
- : operator.StateScan<ByteOrEof, Utf8State, list.List<i32>>
107
- = state => input => input === null ? utf8EofToCodePointOp(state) : utf8ByteToCodePointOp(state)(input)
107
+ : operator.StateScan<ByteOrEof, Utf8State, List<i32>>
108
+ = state => input => input === null ? utf8EofToCodePointOp(state) : utf8ByteToCodePointOp(state)(input)
108
109
 
109
110
  const eofList
110
- : list.List<ByteOrEof>
111
- = [null]
111
+ : List<ByteOrEof>
112
+ = [null]
112
113
 
113
114
  export const toCodePointList
114
- : (input: list.List<u8>) => list.List<i32>
115
- = input => flat(stateScan(utf8ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
115
+ : (input: List<u8>) => List<i32>
116
+ = 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, 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 = reduce(addition)(0n)
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 * 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'
@@ -47,13 +46,17 @@ const difference
47
46
 
48
47
  // additional operations
49
48
 
50
- export const set = compose(one)(union)
49
+ export const set
50
+ : (_: number) => (b: ByteSet) => ByteSet
51
+ = compose(one)(union)
51
52
 
52
- export const setRange = compose(range)(union)
53
+ export const setRange
54
+ : (_: readonly [number, number]) => (b: ByteSet) => ByteSet
55
+ = compose(range)(union)
53
56
 
54
57
  export const unset
55
- : (n: Byte) => (s: ByteSet) => ByteSet
56
- = n => s => difference(s)(one(n))
58
+ : (n: Byte) => (s: ByteSet) => ByteSet
59
+ = n => s => difference(s)(one(n))
57
60
 
58
61
  const counter = reverse(countdown(256))
59
62
 
@@ -58,6 +58,8 @@ export const max
58
58
  : Reduce<number>
59
59
  = a => b => a > b ? a : b
60
60
 
61
- export const increment = addition(1)
61
+ export const increment
62
+ : (b: number) => number
63
+ = addition(1)
62
64
 
63
65
  export const counter = () => increment
@@ -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
 
@@ -219,7 +222,9 @@ export const isEmpty
219
222
  .then(logicalNot)
220
223
  .result
221
224
 
222
- export const every = fn(map(logicalNot))
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: operator.Scan<I, O>) => (ne: NonEmpty<I>) => List<O>
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: operator.Scan<I, O>) => (input: List<I>) => Thunk<O>
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: operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>
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: operator.Fold<I, O>) => (init: O) => (input: List<I>) => Thunk<O>
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: operator.Fold<I, O>) => (init: O) => (input: List<I>) => O
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: operator.Reduce<T>) => <D>(def: D) => (input: List<T>) => D|T
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
- : operator.StateScan<T, number, Entry<T>>
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: operator.Equal<T>) => (a: List<T>) => (b: List<T>) => boolean
336
+ : <T>(e: Equal<T>) => (a: List<T>) => (b: List<T>) => boolean
332
337
  = e => {
333
- type T = typeof e extends operator.Equal<infer T> ? T : never
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 => () => {
@@ -1,16 +1,20 @@
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, 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 = reduce(addition)(0)
6
+ export const sum
7
+ : (input: List<number>) => number
8
+ = reduce(addition)(0)
9
9
 
10
- export const min = reduce(minOp)(null)
10
+ export const min
11
+ : (input: List<number>) => number | null
12
+ = reduce(minOp)(null)
11
13
 
12
- export const max = reduce(maxOp)(null)
14
+ export const max
15
+ : (input: List<number>) => number | null
16
+ = reduce(maxOp)(null)
13
17
 
14
18
  export const cmp
15
- : (a: number) => (b: number) => compare.Sign
16
- = unsafeCmp
19
+ : (a: number) => (b: number) => compare.Sign
20
+ = unsafeCmp
@@ -1,24 +1,26 @@
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
12
- = o => listReduce(o)('')
9
+ : (o: Reduce<string>) => (input: list.List<string>) => string
10
+ = o => listReduce(o)('')
13
11
 
14
- export const join = compose(joinOp)(reduce)
12
+ export const join
13
+ : (_: string) => (input: list.List<string>) => string
14
+ = compose(joinOp)(reduce)
15
15
 
16
- export const concat = reduce(concatOp)
16
+ export const concat
17
+ : (input: list.List<string>) => string
18
+ = reduce(concatOp)
17
19
 
18
20
  export const repeat
19
- : (n: string) => (v: number) => string
20
- = v => compose(listRepeat(v))(concat)
21
+ : (n: string) => (v: number) => string
22
+ = v => compose(listRepeat(v))(concat)
21
23
 
22
24
  export const cmp
23
- : (a: string) => (b: string) => compare.Sign
24
- = unsafeCmp
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 * 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
@@ -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 = fold(set)(null)
31
+ export const fromValues
32
+ : (input: List<string>) => StringSet
33
+ = fold(set)(null)
34
34
 
35
35
  export const remove
36
- : (value: string) => (s: StringSet) => StringSet
37
- = compose(cmp)(btreeRemove)
36
+ : (value: string) => (s: StringSet) => StringSet
37
+ = compose(cmp)(btreeRemove)