Skip to content

Latest commit

 

History

History
101 lines (57 loc) · 2.11 KB

loopstrategy.md

File metadata and controls

101 lines (57 loc) · 2.11 KB

lexureLoopStrategy

Interface: LoopStrategy <A, Z, E>

A strategy for running an input loop.

Type parameters

  • A

Input type.

  • Z

Output type.

  • E

Error type.

Hierarchy

  • LoopStrategy

Index

Methods

Methods

getInput

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

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.


optional onInputError

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.


optional onParseError

  • 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.