Comparing version 0.0.747 to 0.0.748
@@ -15,4 +15,5 @@ import { AtomicPromise } from './promise'; | ||
extract(): b; | ||
extract(left: (a: a) => b): b; | ||
extract<c>(left: (a: a) => c): b | c; | ||
extract<c, d>(left: (a: a) => c, right: (b: b) => d): c | d; | ||
extract<c>(left: (a: a) => c, right: (b: b) => c): c; | ||
} | ||
@@ -46,4 +47,5 @@ | ||
public extract(): b; | ||
public extract<c>(left: (a: any) => c): b | c; | ||
public extract<c, d>(left: (a: any) => c, right: (b: b) => d): c | d; | ||
public extract(left: (a: never) => b): b; | ||
public extract<c>(left: (a: never) => c): b; | ||
public extract<c>(left: (a: never) => c, right: (b: b) => c): c; | ||
public extract<c>(left?: (a: never) => c, right?: (b: b) => c): b | c { | ||
@@ -82,3 +84,3 @@ if (right !== undefined) return right(this.value); | ||
public extract<c>(left: (a: a) => c): c; | ||
public extract<c, d>(left: (a: a) => c, right: (b: any) => d): c | d; | ||
public extract<c>(left: (a: a) => c, right: (b: never) => c): c; | ||
public extract<c>(left?: (a: a) => c): c { | ||
@@ -85,0 +87,0 @@ if (left !== undefined) return left(this.value); |
@@ -16,2 +16,3 @@ import { AtomicPromise } from './promise'; | ||
extract(): a; | ||
extract(nothing: () => a): a; | ||
extract<b>(nothing: () => b): a | b; | ||
@@ -50,2 +51,3 @@ extract<b>(nothing: () => b, just: (a: a) => b): b; | ||
public extract(): a; | ||
public extract(nothing: () => a): a; | ||
public extract<b>(nothing: () => b): a | b; | ||
@@ -52,0 +54,0 @@ public extract<b>(nothing: () => b, just: (a: a) => b): b; |
@@ -38,2 +38,3 @@ import { Monad } from './monad'; | ||
public extract(): b; | ||
public extract(left: (a: a) => b): b; | ||
public extract<c>(left: (a: a) => c): b | c; | ||
@@ -78,19 +79,2 @@ public extract<c>(left: (a: a) => c, right: (b: b) => c): c; | ||
export class Left<a> extends Either<a, never> { | ||
constructor(private value: a) { | ||
super(throwCallError); | ||
} | ||
public override bind<c>(f: (b: never) => Either<a, c>): Left<a> { | ||
return this; | ||
assert(f); | ||
} | ||
public override extract(): never; | ||
public override extract<c>(left: (a: a) => c): c; | ||
public override extract<c>(left: (a: a) => c, right: (b: never) => c): c; | ||
public override extract<c>(left?: (a: a) => c): c { | ||
if (left !== undefined) return left(this.value); | ||
throw this.value; | ||
} | ||
} | ||
export class Right<b> extends Either<never, b> { | ||
@@ -107,2 +91,3 @@ constructor(private readonly value: b) { | ||
public override extract(): b; | ||
public override extract(left: (a: never) => b): b; | ||
public override extract<c>(left: (a: never) => c): b; | ||
@@ -117,4 +102,21 @@ public override extract<c>(left: (a: never) => c, right: (b: b) => c): c; | ||
export class Left<a> extends Either<a, never> { | ||
constructor(private value: a) { | ||
super(throwCallError); | ||
} | ||
public override bind<c>(f: (b: never) => Either<a, c>): Left<a> { | ||
return this; | ||
assert(f); | ||
} | ||
public override extract(): never; | ||
public override extract<c>(left: (a: a) => c): c; | ||
public override extract<c>(left: (a: a) => c, right: (b: never) => c): c; | ||
public override extract<c>(left?: (a: a) => c): c { | ||
if (left !== undefined) return left(this.value); | ||
throw this.value; | ||
} | ||
} | ||
function throwCallError(): never { | ||
throw new Error(`Spica: Either: Invalid thunk call.`); | ||
} |
@@ -41,2 +41,3 @@ import { MonadPlus } from './monadplus'; | ||
public extract(): a; | ||
public extract(nothing: () => a): a; | ||
public extract<b>(nothing: () => b): a | b; | ||
@@ -88,2 +89,3 @@ public extract<b>(nothing: () => b, just: (a: a) => b): b; | ||
public override extract(): a; | ||
public override extract(nothing: () => a): a; | ||
public override extract<b>(nothing: () => b): a; | ||
@@ -90,0 +92,0 @@ public override extract<b>(nothing: () => b, just: (a: a) => b): b; |
{ | ||
"name": "spica", | ||
"version": "0.0.747", | ||
"version": "0.0.748", | ||
"description": "Supervisor, Coroutine, Channel, select, AtomicPromise, Cancellation, Cache, List, Queue, Stack, and some utils.", | ||
@@ -5,0 +5,0 @@ "private": false, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
617973
16859