functype 0.4.2 → 0.8.0

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.
Files changed (152) hide show
  1. package/dist/chunk-2I2NKDFN.mjs +1 -0
  2. package/dist/chunk-3Y43FJKZ.mjs +1 -0
  3. package/dist/chunk-4AEODSGH.mjs +1 -0
  4. package/dist/chunk-4PGXHDAS.js +1 -0
  5. package/dist/chunk-E3BAZBU2.js +1 -0
  6. package/dist/chunk-E6RS47F7.js +1 -0
  7. package/dist/chunk-FMHIRYL5.mjs +1 -0
  8. package/dist/chunk-GPS3OL5F.mjs +1 -0
  9. package/dist/chunk-HJAAA6CD.mjs +1 -0
  10. package/dist/chunk-KWPKGISB.js +1 -0
  11. package/dist/chunk-OXLZ6UIZ.js +1 -0
  12. package/dist/chunk-PMZTOIT2.js +1 -0
  13. package/dist/chunk-REXFLQTJ.js +1 -0
  14. package/dist/chunk-TVCOFH5I.js +1 -0
  15. package/dist/chunk-VK5GL6NM.mjs +1 -0
  16. package/dist/chunk-VUD7L2T6.mjs +1 -0
  17. package/dist/chunk-WDHUQRFT.js +1 -0
  18. package/dist/chunk-ZMF3MVW7.mjs +1 -0
  19. package/dist/collections/index.d.mts +1 -1
  20. package/dist/collections/index.d.ts +1 -1
  21. package/dist/either/Either.d.mts +1 -1
  22. package/dist/either/Either.d.ts +1 -1
  23. package/dist/either/Either.js +1 -1
  24. package/dist/either/Either.mjs +1 -1
  25. package/dist/either/index.d.mts +1 -1
  26. package/dist/either/index.d.ts +1 -1
  27. package/dist/either/index.js +1 -1
  28. package/dist/either/index.mjs +1 -1
  29. package/dist/error/ParseError.d.mts +6 -2
  30. package/dist/error/ParseError.d.ts +6 -2
  31. package/dist/error/ParseError.js +1 -1
  32. package/dist/error/ParseError.mjs +1 -1
  33. package/dist/functor/index.d.mts +11 -11
  34. package/dist/functor/index.d.ts +11 -11
  35. package/dist/index-BB5a793T.d.mts +208 -0
  36. package/dist/index-DyWcaZaG.d.ts +208 -0
  37. package/dist/index.d.mts +3 -3
  38. package/dist/index.d.ts +3 -3
  39. package/dist/index.js +1 -1
  40. package/dist/index.mjs +1 -1
  41. package/dist/iterable/Seq.d.mts +1 -1
  42. package/dist/iterable/Seq.d.ts +1 -1
  43. package/dist/iterable/Seq.js +1 -1
  44. package/dist/iterable/Seq.mjs +1 -1
  45. package/dist/iterable/index.d.mts +1 -1
  46. package/dist/iterable/index.d.ts +1 -1
  47. package/dist/iterable/index.js +1 -1
  48. package/dist/iterable/index.mjs +1 -1
  49. package/dist/list/List.d.mts +1 -1
  50. package/dist/list/List.d.ts +1 -1
  51. package/dist/list/List.js +1 -1
  52. package/dist/list/List.mjs +1 -1
  53. package/dist/list/index.d.mts +1 -1
  54. package/dist/list/index.d.ts +1 -1
  55. package/dist/list/index.js +1 -1
  56. package/dist/list/index.mjs +1 -1
  57. package/dist/map/Map.d.mts +1 -1
  58. package/dist/map/Map.d.ts +1 -1
  59. package/dist/map/Map.js +1 -1
  60. package/dist/map/Map.mjs +1 -1
  61. package/dist/map/index.d.mts +1 -1
  62. package/dist/map/index.d.ts +1 -1
  63. package/dist/map/index.js +1 -1
  64. package/dist/map/index.mjs +1 -1
  65. package/dist/map/shim.js +1 -1
  66. package/dist/map/shim.mjs +1 -1
  67. package/dist/option/Option.d.mts +1 -1
  68. package/dist/option/Option.d.ts +1 -1
  69. package/dist/option/Option.js +1 -1
  70. package/dist/option/Option.mjs +1 -1
  71. package/dist/option/index.d.mts +1 -1
  72. package/dist/option/index.d.ts +1 -1
  73. package/dist/option/index.js +1 -1
  74. package/dist/option/index.mjs +1 -1
  75. package/dist/set/Set.d.mts +1 -1
  76. package/dist/set/Set.d.ts +1 -1
  77. package/dist/set/Set.js +1 -1
  78. package/dist/set/Set.mjs +1 -1
  79. package/dist/set/index.d.mts +1 -1
  80. package/dist/set/index.d.ts +1 -1
  81. package/dist/set/index.js +1 -1
  82. package/dist/set/index.mjs +1 -1
  83. package/dist/set/shim.js +1 -1
  84. package/dist/set/shim.mjs +1 -1
  85. package/dist/try/Try.d.mts +1 -1
  86. package/dist/try/Try.d.ts +1 -1
  87. package/dist/try/Try.js +1 -1
  88. package/dist/try/Try.mjs +1 -1
  89. package/dist/try/index.d.mts +1 -1
  90. package/dist/try/index.d.ts +1 -1
  91. package/dist/try/index.js +1 -1
  92. package/dist/try/index.mjs +1 -1
  93. package/dist/tuple/Tuple.d.mts +7 -15
  94. package/dist/tuple/Tuple.d.ts +7 -15
  95. package/dist/tuple/Tuple.js +1 -1
  96. package/dist/tuple/Tuple.mjs +1 -1
  97. package/dist/tuple/index.d.mts +0 -1
  98. package/dist/tuple/index.d.ts +0 -1
  99. package/dist/tuple/index.js +1 -1
  100. package/dist/tuple/index.mjs +1 -1
  101. package/dist/util/index.d.mts +1 -1
  102. package/dist/util/index.d.ts +1 -1
  103. package/dist/util/index.js +1 -1
  104. package/dist/util/index.mjs +1 -1
  105. package/dist/util/isIterable.js +1 -1
  106. package/dist/util/isIterable.mjs +1 -1
  107. package/lib/collections/index.d.ts +6 -6
  108. package/lib/either/Either.d.ts +28 -28
  109. package/lib/either/index.d.ts +1 -1
  110. package/lib/error/ParseError.d.ts +6 -2
  111. package/lib/functor/index.d.ts +10 -10
  112. package/lib/index.d.ts +7 -4
  113. package/lib/iterable/Seq.d.ts +27 -24
  114. package/lib/iterable/index.d.ts +7 -7
  115. package/lib/list/List.d.ts +19 -21
  116. package/lib/list/index.d.ts +4 -3
  117. package/lib/map/Map.d.ts +14 -35
  118. package/lib/map/index.d.ts +1 -1
  119. package/lib/option/Option.d.ts +28 -40
  120. package/lib/option/index.d.ts +6 -5
  121. package/lib/set/Set.d.ts +15 -18
  122. package/lib/set/index.d.ts +1 -1
  123. package/lib/try/Try.d.ts +24 -18
  124. package/lib/try/index.d.ts +1 -1
  125. package/lib/tuple/Tuple.d.ts +6 -13
  126. package/lib/tuple/index.d.ts +5 -1
  127. package/lib/util/index.d.ts +1 -1
  128. package/package.json +6 -6
  129. package/dist/chunk-2XH6TPQK.mjs +0 -1
  130. package/dist/chunk-35UIDXTO.js +0 -1
  131. package/dist/chunk-3APFKSCC.js +0 -1
  132. package/dist/chunk-3EH27NX2.js +0 -1
  133. package/dist/chunk-74TKYQJS.mjs +0 -0
  134. package/dist/chunk-BYDMB2VV.js +0 -1
  135. package/dist/chunk-CFYIJKWF.mjs +0 -1
  136. package/dist/chunk-GTO34VMN.mjs +0 -1
  137. package/dist/chunk-HC3O3O2B.mjs +0 -1
  138. package/dist/chunk-HOO2EPER.mjs +0 -1
  139. package/dist/chunk-IC6AOOR5.mjs +0 -1
  140. package/dist/chunk-JR557W27.mjs +0 -1
  141. package/dist/chunk-KY3WKBLM.mjs +0 -1
  142. package/dist/chunk-O2XFH626.js +0 -1
  143. package/dist/chunk-QQAQYRPV.js +0 -1
  144. package/dist/chunk-RM3O3IPT.js +0 -1
  145. package/dist/chunk-SKJIJETA.js +0 -1
  146. package/dist/chunk-T7AA7TJX.mjs +0 -1
  147. package/dist/chunk-TYHKMGLC.mjs +0 -1
  148. package/dist/chunk-V5UFW2E4.js +0 -1
  149. package/dist/chunk-XVHCBGUW.js +0 -1
  150. package/dist/chunk-ZTL76QDL.js +0 -1
  151. package/dist/index-Dbjb4MUT.d.ts +0 -232
  152. package/dist/index-UMWeD2QH.d.mts +0 -232
@@ -1,20 +1,12 @@
1
- import { ArrayType, _ArrayFunctor_ } from '../functor/index.js';
1
+ import { ArrayType, ArrayFunctor } from '../functor/index.js';
2
2
 
3
- type _Tuple_<T extends ArrayType> = _ArrayFunctor_<T> & {
4
- get(index: number): T[number];
5
- getAs<U>(index: number, f?: (item: T) => boolean): U;
6
- map<U extends any[]>(f: (value: T) => U): _Tuple_<U>;
7
- flatMap<U extends any[]>(f: (value: T) => _Tuple_<U>): _Tuple_<U>;
8
- toArray(): T;
9
- };
10
- declare class Tuple<T extends ArrayType> implements _Tuple_<T> {
11
- private readonly values;
12
- constructor(values: T);
3
+ type Tuple<T extends ArrayType> = {
4
+ get<K extends number>(index: K): T[K];
13
5
  map<U extends ArrayType>(f: (value: T) => U): Tuple<U>;
14
6
  flatMap<U extends ArrayType>(f: (value: T) => Tuple<U>): Tuple<U>;
15
- get(index: number): T[number];
16
- getAs<U>(index: number, f?: (item: T) => boolean): U;
17
7
  toArray(): T;
18
- }
8
+ [Symbol.iterator](): Iterator<T[number]>;
9
+ } & ArrayFunctor<T>;
10
+ declare const Tuple: <T extends ArrayType>(values: T) => Tuple<T>;
19
11
 
20
- export { Tuple, type _Tuple_ };
12
+ export { Tuple };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkV5UFW2E4js = require('../chunk-V5UFW2E4.js');require('../chunk-O2XFH626.js');exports.Tuple = _chunkV5UFW2E4js.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOXLZ6UIZjs = require('../chunk-OXLZ6UIZ.js');exports.Tuple = _chunkOXLZ6UIZjs.a;
@@ -1 +1 @@
1
- import{a}from"../chunk-2XH6TPQK.mjs";import"../chunk-JR557W27.mjs";export{a as Tuple};
1
+ import{a}from"../chunk-2I2NKDFN.mjs";export{a as Tuple};
@@ -1,6 +1,5 @@
1
1
  import { ArrayType } from '../functor/index.mjs';
2
2
  import { Tuple } from './Tuple.mjs';
3
- export { _Tuple_ } from './Tuple.mjs';
4
3
 
5
4
  declare const t: <T extends ArrayType>(values: T) => Tuple<T>;
6
5
  declare const tuple: <T extends ArrayType>(values: T) => Tuple<T>;
@@ -1,6 +1,5 @@
1
1
  import { ArrayType } from '../functor/index.js';
2
2
  import { Tuple } from './Tuple.js';
3
- export { _Tuple_ } from './Tuple.js';
4
3
 
5
4
  declare const t: <T extends ArrayType>(values: T) => Tuple<T>;
6
5
  declare const tuple: <T extends ArrayType>(values: T) => Tuple<T>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkSKJIJETAjs = require('../chunk-SKJIJETA.js');var _chunkV5UFW2E4js = require('../chunk-V5UFW2E4.js');require('../chunk-O2XFH626.js');exports.Tuple = _chunkV5UFW2E4js.a; exports.t = _chunkSKJIJETAjs.a; exports.tuple = _chunkSKJIJETAjs.b;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkE3BAZBU2js = require('../chunk-E3BAZBU2.js');var _chunkOXLZ6UIZjs = require('../chunk-OXLZ6UIZ.js');exports.Tuple = _chunkOXLZ6UIZjs.a; exports.t = _chunkE3BAZBU2js.a; exports.tuple = _chunkE3BAZBU2js.b;
@@ -1 +1 @@
1
- import{a as b,b as c}from"../chunk-HOO2EPER.mjs";import{a}from"../chunk-2XH6TPQK.mjs";import"../chunk-JR557W27.mjs";export{a as Tuple,b as t,c as tuple};
1
+ import{a as b,b as c}from"../chunk-4AEODSGH.mjs";import{a}from"../chunk-2I2NKDFN.mjs";export{a as Tuple,b as t,c as tuple};
@@ -1,5 +1,5 @@
1
+ import { E as Either } from '../index-BB5a793T.mjs';
1
2
  import { ParseError } from '../error/ParseError.mjs';
2
- import { E as Either } from '../index-UMWeD2QH.mjs';
3
3
  import '../functor/index.mjs';
4
4
  import '../tuple/Tuple.mjs';
5
5
  import '../tuple/index.mjs';
@@ -1,5 +1,5 @@
1
+ import { E as Either } from '../index-DyWcaZaG.js';
1
2
  import { ParseError } from '../error/ParseError.js';
2
- import { E as Either } from '../index-Dbjb4MUT.js';
3
3
  import '../functor/index.js';
4
4
  import '../tuple/Tuple.js';
5
5
  import '../tuple/index.js';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBYDMB2VVjs = require('../chunk-BYDMB2VV.js');require('../chunk-3EH27NX2.js');var _chunkZTL76QDLjs = require('../chunk-ZTL76QDL.js');require('../chunk-RM3O3IPT.js');require('../chunk-XVHCBGUW.js');require('../chunk-3APFKSCC.js');require('../chunk-BNNK42JC.js');require('../chunk-3VJERXBP.js');require('../chunk-O2XFH626.js');var n=s=>{let r=parseInt(s,10);return isNaN(r)?_chunkBYDMB2VVjs.a.call(void 0, new (0, _chunkZTL76QDLjs.a)(`${r}`)):_chunkBYDMB2VVjs.b.call(void 0, r)};exports.parseNumber = n;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4PGXHDASjs = require('../chunk-4PGXHDAS.js');require('../chunk-TVCOFH5I.js');require('../chunk-KWPKGISB.js');require('../chunk-3VJERXBP.js');var _chunkE6RS47F7js = require('../chunk-E6RS47F7.js');require('../chunk-WDHUQRFT.js');require('../chunk-BNNK42JC.js');var n=s=>{let r=parseInt(s,10);return isNaN(r)?_chunk4PGXHDASjs.a.call(void 0, _chunkE6RS47F7js.a.call(void 0, `${r}`)):_chunk4PGXHDASjs.b.call(void 0, r)};exports.parseNumber = n;
@@ -1 +1 @@
1
- import{a as e,b as t}from"../chunk-HC3O3O2B.mjs";import"../chunk-GTO34VMN.mjs";import{a as o}from"../chunk-CFYIJKWF.mjs";import"../chunk-KY3WKBLM.mjs";import"../chunk-74TKYQJS.mjs";import"../chunk-TYHKMGLC.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-JR557W27.mjs";var n=s=>{let r=parseInt(s,10);return isNaN(r)?e(new o(`${r}`)):t(r)};export{n as parseNumber};
1
+ import{a as e,b as t}from"../chunk-3Y43FJKZ.mjs";import"../chunk-HJAAA6CD.mjs";import"../chunk-GPS3OL5F.mjs";import"../chunk-HA5XD5KC.mjs";import{a as o}from"../chunk-VK5GL6NM.mjs";import"../chunk-FMHIRYL5.mjs";import"../chunk-RRAIFS3D.mjs";var n=s=>{let r=parseInt(s,10);return isNaN(r)?e(o(`${r}`)):t(r)};export{n as parseNumber};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBNNK42JCjs = require('../chunk-BNNK42JC.js');require('../chunk-O2XFH626.js');exports.isIterable = _chunkBNNK42JCjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBNNK42JCjs = require('../chunk-BNNK42JC.js');exports.isIterable = _chunkBNNK42JCjs.a;
@@ -1 +1 @@
1
- import{a}from"../chunk-RRAIFS3D.mjs";import"../chunk-JR557W27.mjs";export{a as isIterable};
1
+ import{a}from"../chunk-RRAIFS3D.mjs";export{a as isIterable};
@@ -1,8 +1,8 @@
1
- import { _Set_ } from "../set";
2
- import { _List_ } from "../list";
3
- export type IConverters<A> = {
4
- toList(): _List_<A>;
5
- toSet(): _Set_<A>;
1
+ import { List } from "../list";
2
+ import { Set } from "../set";
3
+ export type Converters<A> = {
4
+ toList(): List<A>;
5
+ toSet(): Set<A>;
6
6
  toString(): string;
7
7
  };
8
- export type _Collection<A> = IConverters<A>;
8
+ export type Collection<A> = Converters<A>;
@@ -1,32 +1,32 @@
1
- import { _Option_ } from "../option";
1
+ import { Functor, Type } from "../functor";
2
2
  import { List } from "../list";
3
- import { _Functor_ } from "../functor";
4
- export type Either<L, R> = {
3
+ import { Option } from "../option";
4
+ import { Typeable } from "../index";
5
+ export type Either<L extends Type, R extends Type> = {
6
+ readonly _tag: "Left" | "Right";
5
7
  value: L | R;
6
- isLeft(): boolean;
7
- isRight(): boolean;
8
- map<U>(f: (value: R) => U): Either<L, U>;
9
- flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
10
- toOption(): _Option_<R>;
11
- toList(): List<R>;
12
- } & _Functor_<R>;
13
- export declare class Right<L, R> implements Either<L, R> {
8
+ isLeft: () => boolean;
9
+ isRight: () => boolean;
10
+ map: <U extends Type>(f: (value: R) => U) => Either<L, U>;
11
+ flatMap: <U extends Type>(f: (value: R) => Either<L, U>) => Either<L, U>;
12
+ toOption: () => Option<R>;
13
+ toList: () => List<R>;
14
+ valueOf: () => {
15
+ _tag: "Left" | "Right";
16
+ value: L | R;
17
+ };
18
+ toString: () => string;
19
+ } & Functor<R> & Typeable;
20
+ export declare const Right: <L, R>(value: R) => Either<L, R>;
21
+ export declare const Left: <L, R>(value: L) => Either<L, R>;
22
+ export declare const isRight: <L, R>(either: Either<L, R>) => either is Either<L, R> & {
14
23
  value: R;
15
- constructor(value: R);
16
- isLeft(): this is Left<L, R>;
17
- isRight(): this is Right<L, R>;
18
- map<U>(f: (value: R) => U): Either<L, U>;
19
- flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
20
- toOption(): _Option_<R>;
21
- toList(): List<R>;
22
- }
23
- export declare class Left<L, R> implements Either<L, R> {
24
+ };
25
+ export declare const isLeft: <L, R>(either: Either<L, R>) => either is Either<L, R> & {
24
26
  value: L;
25
- constructor(value: L);
26
- isLeft(): this is Left<L, R>;
27
- isRight(): this is Right<L, R>;
28
- map<U>(_f: (value: R) => U): Either<L, U>;
29
- flatMap<U>(_f: (value: R) => Either<L, U>): Either<L, U>;
30
- toOption(): _Option_<R>;
31
- toList(): List<R>;
32
- }
27
+ };
28
+ export declare const tryCatch: <L, R>(f: () => R, onError: (error: unknown) => L) => Either<L, R>;
29
+ export declare const match: <L, R, U>(either: Either<L, R>, patterns: {
30
+ Left: (value: L) => U;
31
+ Right: (value: R) => U;
32
+ }) => U;
@@ -1,4 +1,4 @@
1
1
  import { Either, Left, Right } from "./Either";
2
2
  export declare const left: <L, R>(value: L) => Either<L, R>;
3
3
  export declare const right: <L, R>(value: R) => Either<L, R>;
4
- export { Left, Right, Either };
4
+ export { Either, Left, Right };
@@ -1,2 +1,6 @@
1
- export declare class ParseError extends Error {
2
- }
1
+ export declare const ParseError: (message?: string) => Error & {
2
+ name: "ParseError";
3
+ };
4
+ export type ParseError = Error & {
5
+ name: "ParseError";
6
+ };
@@ -1,15 +1,15 @@
1
- export type SingleType = any;
1
+ export type SingleType = unknown;
2
2
  export type ArrayType = SingleType[];
3
3
  export type Type = SingleType | ArrayType;
4
- export type _AbstractFunctor_<A extends Type> = {
5
- map(f: (value: A) => Type): _AbstractFunctor_<Type>;
6
- flatMap(f: (value: A) => _AbstractFunctor_<Type>): _AbstractFunctor_<Type>;
4
+ export type AbstractFunctor<A extends Type> = {
5
+ map(f: (value: A) => Type): AbstractFunctor<Type>;
6
+ flatMap(f: (value: A) => AbstractFunctor<Type>): AbstractFunctor<Type>;
7
7
  };
8
- export type _Functor_<A extends Type> = _AbstractFunctor_<A> & {
9
- map<B extends Type>(f: (value: A) => B): _Functor_<B>;
10
- flatMap<B extends Type>(f: (value: A) => _Functor_<B>): _Functor_<B>;
8
+ export type Functor<A extends Type> = AbstractFunctor<A> & {
9
+ map<B extends Type>(f: (value: A) => B): Functor<B>;
10
+ flatMap<B extends Type>(f: (value: A) => Functor<B>): Functor<B>;
11
11
  };
12
- export type _ArrayFunctor_<A extends ArrayType> = _AbstractFunctor_<A> & {
13
- map<U extends ArrayType>(f: (value: A) => U): _ArrayFunctor_<U>;
14
- flatMap<U extends ArrayType>(f: (value: A) => _ArrayFunctor_<U>): _ArrayFunctor_<U>;
12
+ export type ArrayFunctor<A extends ArrayType> = AbstractFunctor<A> & {
13
+ map<U extends ArrayType>(f: (value: A) => U): ArrayFunctor<U>;
14
+ flatMap<U extends ArrayType>(f: (value: A) => ArrayFunctor<U>): ArrayFunctor<U>;
15
15
  };
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { _Functor_, Type } from "./functor";
2
- export type _Traversable_<A extends Type> = _Functor_<A> & {
1
+ import { Functor, Type } from "./functor";
2
+ export type Traversable<A extends Type> = Functor<A> & {
3
3
  get size(): number;
4
4
  get isEmpty(): boolean;
5
5
  contains(value: A): boolean;
@@ -8,12 +8,15 @@ export type _Traversable_<A extends Type> = _Functor_<A> & {
8
8
  foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
9
9
  foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
10
10
  };
11
+ export * from "./either";
11
12
  export * from "./functor";
12
13
  export * from "./iterable";
13
14
  export * from "./list";
14
15
  export * from "./map";
15
16
  export * from "./option";
16
- export * from "./either";
17
17
  export * from "./set";
18
- export * from "./tuple";
19
18
  export * from "./try";
19
+ export * from "./tuple";
20
+ export type Typeable = {
21
+ _tag: Type;
22
+ };
@@ -1,25 +1,28 @@
1
+ import { Option } from "../option";
1
2
  import { _Iterable_ } from "./index";
2
- import { _Option_ } from "../option";
3
- export declare class Seq<A> implements _Iterable_<A> {
4
- protected readonly values: Iterable<A>;
5
- constructor(values?: Iterable<A> | _Iterable_<A>);
6
- readonly [n: number]: A;
7
- get length(): number;
8
- map<B>(f: (a: A) => B): _Iterable_<B>;
9
- flatMap<B>(f: (a: A) => _Iterable_<B>): _Iterable_<B>;
10
- forEach(f: (a: A) => void): void;
11
- count(p: (x: A) => boolean): number;
12
- exists(p: (a: A) => boolean): Boolean;
13
- filter(p: (a: A) => boolean): _Iterable_<A>;
14
- filterNot(p: (a: A) => boolean): _Iterable_<A>;
15
- find(p: (a: A) => boolean): _Option_<A>;
16
- get head(): A;
17
- get headOption(): _Option_<A>;
18
- get isEmpty(): boolean;
19
- get size(): number;
20
- toArray(): A[];
21
- reduce(f: (prev: A, curr: A) => A): A;
22
- reduceRight(f: (prev: A, curr: A) => A): A;
23
- foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
24
- foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
25
- }
3
+ export type Seq<A> = {
4
+ readonly length: number;
5
+ readonly [Symbol.iterator]: () => Iterator<A>;
6
+ map: <B>(f: (a: A) => B) => Seq<B>;
7
+ flatMap: <B>(f: (a: A) => _Iterable_<B>) => Seq<B>;
8
+ forEach: (f: (a: A) => void) => void;
9
+ count: (p: (x: A) => boolean) => number;
10
+ exists: (p: (a: A) => boolean) => boolean;
11
+ filter: (p: (a: A) => boolean) => Seq<A>;
12
+ filterNot: (p: (a: A) => boolean) => Seq<A>;
13
+ find: (p: (a: A) => boolean) => Option<A>;
14
+ readonly head: A;
15
+ readonly headOption: Option<A>;
16
+ readonly isEmpty: boolean;
17
+ readonly size: number;
18
+ toArray: () => A[];
19
+ reduce: (f: (prev: A, curr: A) => A) => A;
20
+ reduceRight: (f: (prev: A, curr: A) => A) => A;
21
+ foldLeft: <B>(z: B) => (op: (b: B, a: A) => B) => B;
22
+ foldRight: <B>(z: B) => (op: (a: A, b: B) => B) => B;
23
+ valueOf: () => {
24
+ values: A[];
25
+ };
26
+ } & _Iterable_<A>;
27
+ export declare const createSeq: <A>(values?: Iterable<A> | _Iterable_<A>) => Seq<A>;
28
+ export declare const Seq: <A>(values?: Iterable<A> | _Iterable_<A>) => Seq<A>;
@@ -1,10 +1,10 @@
1
- import { _Functor_, Type } from "../functor";
2
- import { _Option_ } from "../option";
1
+ import { Functor, Type } from "../functor";
2
+ import { Option } from "../option";
3
3
  export type _Iterable_<A extends Type> = {
4
4
  count(p: (x: A) => boolean): number;
5
- find(p: (a: A) => boolean): _Option_<A>;
5
+ find(p: (a: A) => boolean): Option<A>;
6
6
  forEach(f: (a: A) => void): void;
7
- exists(p: (a: A) => boolean): Boolean;
7
+ exists(p: (a: A) => boolean): boolean;
8
8
  filter(p: (a: A) => boolean): _Iterable_<A>;
9
9
  filterNot(p: (a: A) => boolean): _Iterable_<A>;
10
10
  reduce(f: (b: A, a: A) => A): A;
@@ -12,11 +12,11 @@ export type _Iterable_<A extends Type> = {
12
12
  foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
13
13
  foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
14
14
  get head(): A;
15
- get headOption(): _Option_<A>;
15
+ get headOption(): Option<A>;
16
16
  get isEmpty(): boolean;
17
17
  map<B extends Type>(f: (a: A) => B): _Iterable_<B>;
18
- flatMap<B extends Type>(f: (a: A) => _Iterable_<B>): _Iterable_<B>;
18
+ flatMap<B extends Type>(f: (a: A) => _Iterable_<B> | Iterable<B>): _Iterable_<B>;
19
19
  get size(): number;
20
20
  toArray(): readonly A[];
21
- } & _Functor_<A>;
21
+ } & Functor<A>;
22
22
  export { Seq } from "./Seq";
@@ -1,23 +1,21 @@
1
+ import { Collection } from "../collections";
1
2
  import { _Iterable_ } from "../iterable";
2
- import { Seq } from "../iterable";
3
- import { _Collection } from "../collections";
3
+ import { Option } from "../option";
4
4
  import { Set } from "../set";
5
- import { _Option_ } from "../option";
6
- export interface _List_<T> extends _Iterable_<T>, ArrayLike<T> {
7
- add(item: T): _List_<T>;
8
- }
9
- export declare class List<A> extends Seq<A> implements _List_<A>, _Collection<A> {
10
- constructor(values?: Iterable<A> | _Iterable_<A>);
11
- readonly [n: number]: A;
12
- map<B>(f: (a: A) => B): List<B>;
13
- flatMap<B>(f: (a: A) => _Iterable_<B>): List<B>;
14
- remove(value: A): List<A>;
15
- contains(value: A): boolean;
16
- add(item: A): List<A>;
17
- removeAt(index: number): List<A>;
18
- get(index: number): _Option_<A>;
19
- concat(other: List<A>): List<A>;
20
- toList(): _List_<A>;
21
- toSet(): Set<A>;
22
- toString(): string;
23
- }
5
+ export type List<A> = {
6
+ add: (item: A) => List<A>;
7
+ map: <B>(f: (a: A) => B) => List<B>;
8
+ flatMap: <B>(f: (a: A) => _Iterable_<B>) => List<B>;
9
+ remove: (value: A) => List<A>;
10
+ contains: (value: A) => boolean;
11
+ removeAt: (index: number) => List<A>;
12
+ get: (index: number) => Option<A>;
13
+ concat: (other: List<A>) => List<A>;
14
+ toList: () => List<A>;
15
+ toSet: () => Set<A>;
16
+ toString: () => string;
17
+ valueOf: () => {
18
+ values: A[];
19
+ };
20
+ } & ArrayLike<A> & _Iterable_<A> & Collection<A>;
21
+ export declare const List: <A>(values?: Iterable<A> | _Iterable_<A>) => List<A>;
@@ -1,3 +1,4 @@
1
- import { List, _List_ } from "./List";
2
- declare const list: <T extends unknown>(items: T[] | undefined) => List<T>;
3
- export { list, List, _List_ };
1
+ import { Type } from "../functor";
2
+ import { List } from "./List";
3
+ declare const list: <T extends Type>(items: T[] | undefined) => List<T>;
4
+ export { list, List };
package/lib/map/Map.d.ts CHANGED
@@ -1,37 +1,16 @@
1
- import { _Tuple_, Tuple } from "../tuple";
2
- import { _Set_ } from "../set";
3
- import { _Option_ } from "../option";
4
- import { _List_ } from "../list";
5
- import { _Traversable_ } from "../index";
6
- import { _Collection } from "../collections";
7
- type SafeTraversable<K, V> = Omit<_Traversable_<_Tuple_<[K, V]>>, "map" | "flatMap">;
8
- export type _Map_<K, V> = {
9
- map<U>(f: (value: any) => U): _Map_<K, U>;
10
- flatMap<U>(f: (value: any) => _Map_<K, U>): _Map_<K, U>;
11
- get(key: K): _Option_<V>;
1
+ import { Collection } from "../collections";
2
+ import { _Iterable_, Traversable } from "../index";
3
+ import { Option } from "../option";
4
+ import { Tuple } from "../tuple";
5
+ type SafeTraversable<K, V> = Omit<Traversable<Tuple<[K, V]>>, "map" | "flatMap">;
6
+ export type Map<K, V> = {
7
+ add(item: Tuple<[K, V]>): Map<K, V>;
8
+ remove(value: K): Map<K, V>;
9
+ map<U>(f: (value: V) => U): Map<K, U>;
10
+ flatMap<K2, V2>(f: (entry: Tuple<[K, V]>) => _Iterable_<[K2, V2]>): Map<K2, V2>;
11
+ get(key: K): Option<V>;
12
12
  getOrElse(key: K, defaultValue: V): V;
13
- orElse(key: K, alternative: _Option_<V>): _Option_<V>;
14
- } & SafeTraversable<K, V> & _Collection<_Tuple_<[K, V]>>;
15
- export declare class Map<K, V> implements _Map_<K, V> {
16
- private values;
17
- private get entries();
18
- constructor(entries?: readonly (readonly [K, V])[] | IterableIterator<[K, V]> | null);
19
- add(item: _Tuple_<[K, V]>): Map<K, V>;
20
- remove(value: _Tuple_<[K, V]>): Map<K, V>;
21
- contains(value: _Tuple_<[K, V]>): boolean;
22
- get size(): number;
23
- map<U>(f: (value: V) => U): _Map_<K, U>;
24
- flatMap<U>(f: (value: V) => _Map_<K, U>): _Map_<K, U>;
25
- reduce(f: (acc: Tuple<[K, V]>, value: Tuple<[K, V]>) => Tuple<[K, V]>): Tuple<[K, V]>;
26
- reduceRight(f: (acc: Tuple<[K, V]>, value: Tuple<[K, V]>) => Tuple<[K, V]>): Tuple<[K, V]>;
27
- foldLeft<B>(z: B): (op: (b: B, a: _Tuple_<[K, V]>) => B) => B;
28
- foldRight<B>(z: B): (op: (a: _Tuple_<[K, V]>, b: B) => B) => B;
29
- get(key: K): _Option_<V>;
30
- getOrElse(key: K, defaultValue: V): V;
31
- get isEmpty(): boolean;
32
- orElse(key: K, alternative: _Option_<V>): _Option_<V>;
33
- toList(): _List_<Tuple<[K, V]>>;
34
- toSet(): _Set_<Tuple<[K, V]>>;
35
- toString(): string;
36
- }
13
+ orElse(key: K, alternative: Option<V>): Option<V>;
14
+ } & SafeTraversable<K, V> & Collection<Tuple<[K, V]>>;
15
+ export declare const Map: <K, V>(entries?: readonly (readonly [K, V])[] | IterableIterator<[K, V]> | null) => Map<K, V>;
37
16
  export {};
@@ -1 +1 @@
1
- export { Map, _Map_ } from "./Map";
1
+ export { Map } from "./Map";
@@ -1,44 +1,32 @@
1
- import { _Functor_, Type } from "../functor";
2
- import { _Traversable_ } from "../index";
1
+ import { Functor, Type } from "../functor";
2
+ import { Traversable, Typeable } from "../index";
3
3
  import { _Iterable_ } from "../iterable";
4
- export type _Option_<T extends Type> = {
4
+ export type Option<T extends Type> = {
5
+ readonly _tag: "Some" | "None";
6
+ readonly value: T | undefined;
7
+ isEmpty: boolean;
5
8
  get(): T;
6
9
  getOrElse(defaultValue: T): T;
7
- orElse(alternative: _Option_<T>): _Option_<T>;
8
- map<U extends Type>(f: (value: T) => U): _Option_<U>;
9
- flatMap<U extends Type>(f: (value: T) => _Option_<U>): _Option_<U>;
10
+ orElse(alternative: Option<T>): Option<T>;
11
+ map<U extends Type>(f: (value: T) => U): Option<U>;
12
+ flatMap<U extends Type>(f: (value: T) => Option<U>): Option<U>;
13
+ reduce<U>(f: (acc: U, value: T) => U): U;
14
+ reduceRight<U>(f: (acc: U, value: T) => U): U;
15
+ foldLeft<B>(z: B): (op: (b: B, a: T) => B) => B;
16
+ foldRight<B>(z: B): (op: (a: T, b: B) => B) => B;
10
17
  toList(): _Iterable_<T>;
11
- valueOf(): Object;
12
- } & _Traversable_<T> & _Functor_<T>;
13
- export declare class Some<A extends Type> implements _Option_<A> {
14
- private value;
15
- constructor(value: A);
16
- get isEmpty(): boolean;
17
- get(): A;
18
- getOrElse(defaultValue: A): A;
19
- orElse(alternative: _Option_<A>): _Option_<A>;
20
- map<U extends Type>(f: (value: A) => U): _Option_<U>;
21
- flatMap<U extends Type>(f: (value: A) => _Option_<U>): _Option_<U>;
22
- reduce<U>(f: (acc: U, value: A) => U): U;
23
- reduceRight<U>(f: (acc: U, value: A) => U): U;
24
- foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
25
- foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
26
- toList(): _Iterable_<A>;
27
- contains(value: A): boolean;
28
- get size(): number;
29
- }
30
- export declare class None<A extends Type> implements _Option_<A> {
31
- get isEmpty(): boolean;
32
- get(): A;
33
- getOrElse(defaultValue: A): A;
34
- orElse(alternative: _Option_<A>): _Option_<A>;
35
- map<U extends Type>(f: (value: A) => U): _Option_<U>;
36
- flatMap<U extends Type>(f: (value: A) => _Option_<U>): _Option_<U>;
37
- reduce(f: (acc: A, value: A) => A): A;
38
- reduceRight(f: (b: A, a: A) => A): A;
39
- foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
40
- foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
41
- toList(): _Iterable_<A>;
42
- contains(value: A): boolean;
43
- get size(): number;
44
- }
18
+ contains(value: T): boolean;
19
+ size: number;
20
+ valueOf(): {
21
+ _tag: "Some" | "None";
22
+ value?: T;
23
+ };
24
+ toString(): string;
25
+ } & Traversable<T> & Functor<T> & Typeable;
26
+ export declare const Some: <T extends Type>(value: T) => Option<T>;
27
+ export declare const None: <T extends Type>() => Option<T>;
28
+ export declare const Option: <T extends Type>(value: T | null | undefined) => Option<T>;
29
+ export declare const match: <T extends Type, U>(option: Option<T>, patterns: {
30
+ Some: (value: T) => U;
31
+ None: () => U;
32
+ }) => U;
@@ -1,5 +1,6 @@
1
- import { None, _Option_, Some } from "./Option";
2
- export declare const option: <T extends unknown>(value?: T) => _Option_<T>;
3
- export declare const some: <T extends unknown>(value: T) => _Option_<T>;
4
- export declare const none: <T extends unknown>() => _Option_<T>;
5
- export { _Option_, Some, None };
1
+ import { Type } from "../functor";
2
+ import { None, Option, Some } from "./Option";
3
+ export declare const option: <T extends Type>(value?: T) => Option<T>;
4
+ export declare const some: <T extends Type>(value: T) => Option<T>;
5
+ export declare const none: <T extends Type>() => Option<T>;
6
+ export { None, Option, Some };
package/lib/set/Set.d.ts CHANGED
@@ -1,18 +1,15 @@
1
- import { _Iterable_, Seq } from "../iterable";
2
- import { _List_ } from "../list";
3
- import { _Collection } from "../collections";
4
- export type _Set_<T> = {
5
- has(value: T): boolean;
6
- } & _Iterable_<T> & _Collection<T>;
7
- export declare class Set<A> extends Seq<A> implements _Set_<A> {
8
- constructor(iterable?: Iterable<A> | _Iterable_<A>);
9
- add(value: A): Set<A>;
10
- remove(value: A): Set<A>;
11
- contains(value: A): boolean;
12
- has(value: A): boolean;
13
- map<B>(f: (a: A) => B): Set<B>;
14
- flatMap<B>(f: (a: A) => _Iterable_<B>): Set<B>;
15
- toList(): _List_<A>;
16
- toSet(): _Set_<A>;
17
- toString(): string;
18
- }
1
+ import { Collection } from "../collections";
2
+ import { _Iterable_ } from "../iterable";
3
+ import { List } from "../list";
4
+ export type Set<A> = {
5
+ add: (value: A) => Set<A>;
6
+ remove: (value: A) => Set<A>;
7
+ contains: (value: A) => boolean;
8
+ has: (value: A) => boolean;
9
+ map: <B>(f: (a: A) => B) => Set<B>;
10
+ flatMap: <B>(f: (a: A) => _Iterable_<B>) => Set<B>;
11
+ toList: () => List<A>;
12
+ toSet: () => Set<A>;
13
+ toString: () => string;
14
+ } & _Iterable_<A> & Collection<A>;
15
+ export declare const Set: <A>(iterable?: Iterable<A> | _Iterable_<A>) => Set<A>;
@@ -1 +1 @@
1
- export { Set, _Set_ } from "./Set";
1
+ export { Set } from "./Set";