From d5c3af89ab8076bcf4107859c1ba6b47a7815142 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 15 Jan 2023 00:13:04 +0530 Subject: chore: some more documentation --- docs/interfaces/effect.Bind.md | 11 +++++++---- docs/interfaces/effect.BindTo.md | 14 ++++++++++---- docs/interfaces/effect.Do.md | 9 ++++++--- docs/interfaces/effect.Kind1.md | 4 ++-- docs/interfaces/effect.Label.md | 9 ++++++--- docs/interfaces/effect.Noop.md | 4 ++-- docs/interfaces/effect.Pure.md | 6 +++--- docs/interfaces/effect.Seq.md | 9 ++++++--- docs/interfaces/test.AssertEqualsK.md | 28 +++++++++++++--------------- docs/interfaces/test.Test.md | 16 +++++++++++----- docs/interfaces/util.ConstK.md | 4 ++-- docs/interfaces/util.IdK.md | 4 ++-- 12 files changed, 70 insertions(+), 48 deletions(-) (limited to 'docs/interfaces') diff --git a/docs/interfaces/effect.Bind.md b/docs/interfaces/effect.Bind.md index 334bd5f..bc42d06 100644 --- a/docs/interfaces/effect.Bind.md +++ b/docs/interfaces/effect.Bind.md @@ -4,20 +4,23 @@ [effect](../modules/effect.md).Bind -Generic interface for declaring effects +Monadic bind an effect to a function (Equivalent to haskell's >>= operator) **`Example`** ```ts -interface MyEffect extends Effect {} +type main = Bind< + ReadFile<"./file.txt">, + () => Print +> ``` ## Type parameters | Name | Type | Description | | :------ | :------ | :------ | -| `_Eff` | extends [`Effect`](effect.Effect.md) | The output generated by the effect (defaults to `unknown`) | -| `_Fn` | extends [`Func`](../modules/effect.md#func) | - | +| `_Eff` | extends [`Effect`](effect.Effect.md) | Effect to evaluate first | +| `_Fn` | extends [`Func`](../modules/effect.md#func) | Function to call with the result of _Eff | ## Hierarchy diff --git a/docs/interfaces/effect.BindTo.md b/docs/interfaces/effect.BindTo.md index c333393..0775364 100644 --- a/docs/interfaces/effect.BindTo.md +++ b/docs/interfaces/effect.BindTo.md @@ -4,20 +4,26 @@ [effect](../modules/effect.md).BindTo -Generic interface for declaring effects +Bind result of evaluating an effect to a label (Equivalent to haskell's <- syntax) + +Note: labels are scoped to outermost Do, Bind, Try, etc scopes **`Example`** ```ts -interface MyEffect extends Effect {} +type main = Do<[ + // contents <- readFile "./file.txt" + BindTo<"contents", ReadFile<"./file.txt">>, + Bind, () => Print> +]> ``` ## Type parameters | Name | Type | Description | | :------ | :------ | :------ | -| `_Name` | extends `string` | The output generated by the effect (defaults to `unknown`) | -| `_Eff` | extends [`Effect`](effect.Effect.md) | - | +| `_Name` | extends `string` | The name of label | +| `_Eff` | extends [`Effect`](effect.Effect.md) | Effect to evaluate | ## Hierarchy diff --git a/docs/interfaces/effect.Do.md b/docs/interfaces/effect.Do.md index 504f9c0..1039bc7 100644 --- a/docs/interfaces/effect.Do.md +++ b/docs/interfaces/effect.Do.md @@ -4,19 +4,22 @@ [effect](../modules/effect.md).Do -Generic interface for declaring effects +Evaluate a sequence of effects in series and get the result of the last effect (Equivalent to haskell's do syntax) **`Example`** ```ts -interface MyEffect extends Effect {} +type main = Bind< + Do<[ Pure<1>, ReadFile<"./foobar.txt"> ]>, + () => Print +> ``` ## Type parameters | Name | Type | Description | | :------ | :------ | :------ | -| `_Effs` | extends [`Effect`](effect.Effect.md)[] | The output generated by the effect (defaults to `unknown`) | +| `_Effs` | extends [`Effect`](effect.Effect.md)[] | List of effects | ## Hierarchy diff --git a/docs/interfaces/effect.Kind1.md b/docs/interfaces/effect.Kind1.md index 0c8600f..dc0ed2f 100644 --- a/docs/interfaces/effect.Kind1.md +++ b/docs/interfaces/effect.Kind1.md @@ -52,7 +52,7 @@ type result = ApplyK #### Defined in -[effect.ts:35](https://github.com/phenax/ts-types-runtime-environment/blob/78e384c/stdlib/effect.ts#L35) +[effect.ts:35](https://github.com/phenax/ts-types-runtime-environment/blob/e75a5a1/stdlib/effect.ts#L35) ___ @@ -62,4 +62,4 @@ ___ #### Defined in -[effect.ts:36](https://github.com/phenax/ts-types-runtime-environment/blob/78e384c/stdlib/effect.ts#L36) +[effect.ts:36](https://github.com/phenax/ts-types-runtime-environment/blob/e75a5a1/stdlib/effect.ts#L36) diff --git a/docs/interfaces/effect.Label.md b/docs/interfaces/effect.Label.md index f4d9c2c..d007d64 100644 --- a/docs/interfaces/effect.Label.md +++ b/docs/interfaces/effect.Label.md @@ -4,19 +4,22 @@ [effect](../modules/effect.md).Label -Generic interface for declaring effects +Access a label defined with [BindTo](effect.BindTo.md) **`Example`** ```ts -interface MyEffect extends Effect {} +type main = Do<[ + BindTo<"contents", ReadFile<"./file.txt">>, + Bind, () => Print> +]> ``` ## Type parameters | Name | Type | Description | | :------ | :------ | :------ | -| `_Name` | extends `string` | The output generated by the effect (defaults to `unknown`) | +| `_Name` | extends `string` | The name of label | ## Hierarchy diff --git a/docs/interfaces/effect.Noop.md b/docs/interfaces/effect.Noop.md index 79cd0d7..9666460 100644 --- a/docs/interfaces/effect.Noop.md +++ b/docs/interfaces/effect.Noop.md @@ -4,12 +4,12 @@ [effect](../modules/effect.md).Noop -Generic interface for declaring effects +Noop effect that does nothing (returns undefined) **`Example`** ```ts -interface MyEffect extends Effect {} +type main = Bind() => Print> ``` ## Hierarchy diff --git a/docs/interfaces/effect.Pure.md b/docs/interfaces/effect.Pure.md index 69fd304..5e179f3 100644 --- a/docs/interfaces/effect.Pure.md +++ b/docs/interfaces/effect.Pure.md @@ -4,19 +4,19 @@ [effect](../modules/effect.md).Pure -Generic interface for declaring effects +Wrap a value inside an effect (Equivalent to haskell's pure function) **`Example`** ```ts -interface MyEffect extends Effect {} +type main = Bind, () => Print> ``` ## Type parameters | Name | Description | | :------ | :------ | -| `V` | The output generated by the effect (defaults to `unknown`) | +| `V` | Value | ## Hierarchy diff --git a/docs/interfaces/effect.Seq.md b/docs/interfaces/effect.Seq.md index 3604873..6e52a12 100644 --- a/docs/interfaces/effect.Seq.md +++ b/docs/interfaces/effect.Seq.md @@ -4,19 +4,22 @@ [effect](../modules/effect.md).Seq -Generic interface for declaring effects +Evaluate a sequence of effects in series and get the list of results **`Example`** ```ts -interface MyEffect extends Effect {} +type main = Bind< + Seq<[ Pure<1>, ReadFile<"./foobar.txt"> ]>, + () => Print +> ``` ## Type parameters | Name | Type | Description | | :------ | :------ | :------ | -| `_Effs` | extends [`Effect`](effect.Effect.md)[] | The output generated by the effect (defaults to `unknown`) | +| `_Effs` | extends [`Effect`](effect.Effect.md)[] | List of effects | ## Hierarchy diff --git a/docs/interfaces/test.AssertEqualsK.md b/docs/interfaces/test.AssertEqualsK.md index b2c2e81..6390521 100644 --- a/docs/interfaces/test.AssertEqualsK.md +++ b/docs/interfaces/test.AssertEqualsK.md @@ -4,27 +4,25 @@ [test](../modules/test.md).AssertEqualsK -An implementation of `* -> *` higher-kinded type +An alternate point-free api for [AssertEquals](../modules/test.md#assertequals) -**`Example`** +**`Type Param`** -You can define a return property for the function body - and use `this['input']` to access the argument - Uses - [ApplyK](../modules/util.md#applyk) +Right value -```ts -interface SomeFunc extends Kind1 { - return: `Your number is ${this['input']}`, -} +**`Example`** -type result = ApplyK +```ts +type main = [ + Bind, AssertEqualsK<63>> +] ``` ## Type parameters -| Name | Type | Description | -| :------ | :------ | :------ | -| `Right` | extends `unknown` | The input type | +| Name | Type | +| :------ | :------ | +| `Right` | extends `unknown` | ## Hierarchy @@ -51,7 +49,7 @@ type result = ApplyK #### Defined in -[effect.ts:35](https://github.com/phenax/ts-types-runtime-environment/blob/78e384c/stdlib/effect.ts#L35) +[effect.ts:35](https://github.com/phenax/ts-types-runtime-environment/blob/e75a5a1/stdlib/effect.ts#L35) ___ @@ -65,4 +63,4 @@ ___ #### Defined in -[test.ts:34](https://github.com/phenax/ts-types-runtime-environment/blob/78e384c/stdlib/test.ts#L34) +[test.ts:77](https://github.com/phenax/ts-types-runtime-environment/blob/e75a5a1/stdlib/test.ts#L77) diff --git a/docs/interfaces/test.Test.md b/docs/interfaces/test.Test.md index b503cc0..583569a 100644 --- a/docs/interfaces/test.Test.md +++ b/docs/interfaces/test.Test.md @@ -1,23 +1,29 @@ [ts-types-lang](../README.md) / [Modules](../modules.md) / [test](../modules/test.md) / Test -# Interface: Test<_m, _effs\> +# Interface: Test<_M, _Effs\> [test](../modules/test.md).Test -Generic interface for declaring effects +Create a test block **`Example`** ```ts -interface MyEffect extends Effect {} +type main = [ + Test<"should check if result is 21", [ + Bind, () => AssertEquals>, + // equivalent to... + Bind, AssertEqualsK<21>>, + ]> +] ``` ## Type parameters | Name | Type | Description | | :------ | :------ | :------ | -| `_m` | extends `string` | The output generated by the effect (defaults to `unknown`) | -| `_effs` | extends [`Effect`](effect.Effect.md)[] | - | +| `_M` | extends `string` | description of the test | +| `_Effs` | extends [`Effect`](effect.Effect.md)[] | List of effects to evaluate | ## Hierarchy diff --git a/docs/interfaces/util.ConstK.md b/docs/interfaces/util.ConstK.md index 71db6c3..1b42f9c 100644 --- a/docs/interfaces/util.ConstK.md +++ b/docs/interfaces/util.ConstK.md @@ -51,7 +51,7 @@ type result = ApplyK #### Defined in -[effect.ts:35](https://github.com/phenax/ts-types-runtime-environment/blob/78e384c/stdlib/effect.ts#L35) +[effect.ts:35](https://github.com/phenax/ts-types-runtime-environment/blob/e75a5a1/stdlib/effect.ts#L35) ___ @@ -65,4 +65,4 @@ ___ #### Defined in -[util.ts:13](https://github.com/phenax/ts-types-runtime-environment/blob/78e384c/stdlib/util.ts#L13) +[util.ts:13](https://github.com/phenax/ts-types-runtime-environment/blob/e75a5a1/stdlib/util.ts#L13) diff --git a/docs/interfaces/util.IdK.md b/docs/interfaces/util.IdK.md index 35bcab6..361cbc0 100644 --- a/docs/interfaces/util.IdK.md +++ b/docs/interfaces/util.IdK.md @@ -45,7 +45,7 @@ type result = ApplyK #### Defined in -[effect.ts:35](https://github.com/phenax/ts-types-runtime-environment/blob/78e384c/stdlib/effect.ts#L35) +[effect.ts:35](https://github.com/phenax/ts-types-runtime-environment/blob/e75a5a1/stdlib/effect.ts#L35) ___ @@ -59,4 +59,4 @@ ___ #### Defined in -[util.ts:9](https://github.com/phenax/ts-types-runtime-environment/blob/78e384c/stdlib/util.ts#L9) +[util.ts:9](https://github.com/phenax/ts-types-runtime-environment/blob/e75a5a1/stdlib/util.ts#L9) -- cgit v1.3.1