aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2023-01-14 10:37:51 +0530
committerAkshay Nair <phenax5@gmail.com>2023-01-14 10:43:20 +0530
commitefe0ab336144d2d965bf355db02762f5cf539c7f (patch)
tree5447c661ffed03e833d7283d3b174bb22fdd2e7a /stdlib
parent2979eda13e25725683aa10292b31f22793c4e0c0 (diff)
downloadts-types-lang-efe0ab336144d2d965bf355db02762f5cf539c7f.tar.gz
ts-types-lang-efe0ab336144d2d965bf355db02762f5cf539c7f.zip
feat: adds func to try/catch
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/effect.ts2
-rw-r--r--stdlib/exception.ts4
-rw-r--r--stdlib/util.ts9
3 files changed, 10 insertions, 5 deletions
diff --git a/stdlib/effect.ts b/stdlib/effect.ts
index 0662d00..341a620 100644
--- a/stdlib/effect.ts
+++ b/stdlib/effect.ts
@@ -7,7 +7,7 @@ export interface Kind1<Inp = unknown, Out = unknown> {
return: Out
}
-type Func<Inp = unknown, Out = unknown>
+export type Func<Inp = unknown, Out = unknown>
= Kind1<Inp, Out>
| (<_T extends Inp>() => Out)
diff --git a/stdlib/exception.ts b/stdlib/exception.ts
index ddb980c..d137a87 100644
--- a/stdlib/exception.ts
+++ b/stdlib/exception.ts
@@ -1,5 +1,5 @@
-import { Effect, Kind1 } from './effect'
+import { Effect, Func } from './effect'
-export interface Try<_E extends Effect, _Catch extends Kind1> extends Effect {}
+export interface Try<_E extends Effect, _Catch extends Func> extends Effect {}
export interface Throw<_E> extends Effect {}
diff --git a/stdlib/util.ts b/stdlib/util.ts
index 20a41fb..cd25d7b 100644
--- a/stdlib/util.ts
+++ b/stdlib/util.ts
@@ -2,12 +2,17 @@ import { Kind1 } from './effect'
export type Let<f extends (...args: any) => any> = ReturnType<f>
-export type Apply<K extends Kind1, Val> = (K & { input: Val })['return']
+export type ApplyK<K extends Kind1, Val> = (K & { input: Val })['return']
-export interface Id extends Kind1 {
+export type Id = <T>() => T
+export interface IdK extends Kind1 {
return: this['input']
}
+export interface ConstK<Val> extends Kind1<unknown, Val> {
+ return: Val
+}
+
type ADTDescr = { _type: string; value: any }
interface ADTConstructor<A extends ADTDescr> extends Kind1<A['value']> {