aboutsummaryrefslogtreecommitdiff
path: root/stdlib/effect.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2023-01-14 18:16:41 +0530
committerAkshay Nair <phenax5@gmail.com>2023-01-14 18:16:41 +0530
commite75a5a15912b8f297fe9c9747f574486d6c4e334 (patch)
tree603cd3b9fa68e6e0bd700fe66fede80e9ae657c9 /stdlib/effect.ts
parent78e384c2f32996478edced59c837a348dec77e57 (diff)
downloadts-types-lang-e75a5a15912b8f297fe9c9747f574486d6c4e334.tar.gz
ts-types-lang-e75a5a15912b8f297fe9c9747f574486d6c4e334.zip
chore: adds some docs
Diffstat (limited to 'stdlib/effect.ts')
-rw-r--r--stdlib/effect.ts46
1 files changed, 46 insertions, 0 deletions
diff --git a/stdlib/effect.ts b/stdlib/effect.ts
index 9b19197..4a994c4 100644
--- a/stdlib/effect.ts
+++ b/stdlib/effect.ts
@@ -1,12 +1,58 @@
+/**
+ * Generic interface for declaring effects
+ * @typeParam T - The output generated by the effect (defaults to `unknown`)
+ *
+ * @example
+ * ```ts
+ * interface MyEffect extends Effect<string[]> {}
+ * ```
+ */
export interface Effect<T = unknown> {
+ /** @hidden */
output: T
}
+/**
+ * An implementation of `* -> *` higher-kinded type
+ *
+ * @typeParam Inp - The input type
+ * @typeParam Out - The output type
+ *
+ * @example
+ * You can define a return property for the function body
+ * and use `this['input']` to access the argument
+ * Uses - {@link util.ApplyK}
+ *
+ * ```ts
+ * interface SomeFunc extends Kind1<number, string> {
+ * return: `Your number is ${this['input']}`,
+ * }
+ *
+ * type result = ApplyK<SomeFunc, 200>
+ * ```
+ */
export interface Kind1<Inp = unknown, Out = unknown> {
input: Inp
return: Out
}
+/**
+ * Generic function definition as a union of a kind and anonymous function
+ *
+ * @typeParam Inp - The input type
+ * @typeParam Out - The output type
+ *
+ * @example
+ * In addition to defining a kind (see - {@link Kind1}),
+ * you can also in some places, use inline lambda functions
+ *
+ * ```ts
+ * type main = Bind<
+ * ReadFile<"./file.txt">,
+ * <contents extends string>() => Print<contents>
+ * >
+ * ```
+ */
export type Func<Inp = unknown, Out = unknown> =
| Kind1<Inp, Out>
| (<_T extends Inp>() => Out)