success
Readable shortcut to create an EitherRight with the literal info "success". Ideal for functions that return only one type of success.
TIP
success is strictly equivalent to right("success", value). For the generic details (info, typing, fuller examples), see the right page.
Interactive example
Syntax
typescript
function success<
const GenericInput extends unknown
>(
input: GenericInput
): EitherSuccess<GenericInput>Parameters
input: Successful value to expose. Its type is preserved.
Return value
An EitherRight whose info is fixed to "success". Combine it with E.hasInformation(result, "success") to get an exhaustive type.
When to use success?
- To express operations that have only one “default” success.
- To get a shorter, more readable syntax than
right("success", value). - To stay consistent with
E.erroron theLeftside.
