A strategy for running an input loop.
- A
Input type.
- Z
Output type.
- E
Error type.
- LoopStrategy
- getInput(): LoopAction<A, Z, E>
Gets new input from somewhere e.g. reading a line.
Returns: LoopAction<A, Z, E>
A loop action that can: step with the input; finish with some parsed value; fail due to an error.
- parse(input: A): LoopAction<null, Z, E>
Parses given input into the desired type.
Parameters:
| Name | Type | Description |
|---|---|---|
| input | A | The input. |
Returns: LoopAction<null, Z, E>
A loop action that can: step on; finish with some parsed value; fail due to an error.
- onInputError(error: E): LoopAction<null, Z, E>
Handles error on getting new input.
This function intercepts the fail case of getInput.
Parameters:
| Name | Type | Description |
|---|---|---|
| error | E | The error encountered. |
Returns: LoopAction<null, Z, E>
A loop action that can: step on; finish with some parsed value; fail due to an error.
- onParseError(error: E, input: A): LoopAction<null, Z, E>
Handles error on parsing input.
This function intercepts the fail case of parse.
Parameters:
| Name | Type | Description |
|---|---|---|
| error | E | The error encountered. |
| input | A | The input that could not be parsed. |
Returns: LoopAction<null, Z, E>
A loop action that can: step on; finish with some parsed value; fail due to an error.