For AI agents: the complete documentation index is available at /byethrow/llms.txt, the full documentation bundle is available at /byethrow/llms-full.txt, and this page is available as Markdown at /byethrow/api/functions/Result.succeed.md.
  • English
  • Function: succeed()

    Creates a Success result from a given value.

    Passing a Promise is allowed, but it is recommended to await it before passing to succeed.

    Type Param

    T

    The type of the value to wrap.

    Examples

    Synchronous Usage

    import { 
    import Result
    Result
    } from '@praha/byethrow';
    const
    const result: Result.Result<42, never>
    result
    =
    import Result
    Result
    .
    function succeed<42>(value: 42): Result.Result<42, never> (+1 overload)

    Creates a Success result from a given value.

    Passing a Promise is allowed, but it is recommended to await it before passing to succeed.

    @typeParamT - The type of the value to wrap.@returnsA Result containing the given value.@example

    Synchronous Usage

    import { Result } from '@praha/byethrow';
    
    const result = Result.succeed(42);
    // Result.Result<42, never>
    @example

    With No Value

    import { Result } from '@praha/byethrow';
    
    const result = Result.succeed();
    // Result.Result<void, never>
    @seecollect - For collect multiple Results into a single Result.@seesequence - For sequence multiple Results into a single Result.@categoryCreators
    succeed
    (42);
    // Result.Result<42, never>

    With No Value

    import { 
    import Result
    Result
    } from '@praha/byethrow';
    const
    const result: Result.Result<void, never>
    result
    =
    import Result
    Result
    .
    function succeed(): Result.Result<void, never> (+1 overload)

    Creates a Success result from a given value.

    Passing a Promise is allowed, but it is recommended to await it before passing to succeed.

    @typeParamT - The type of the value to wrap.@returnsA Result containing the given value.@example

    Synchronous Usage

    import { Result } from '@praha/byethrow';
    
    const result = Result.succeed(42);
    // Result.Result<42, never>
    @example

    With No Value

    import { Result } from '@praha/byethrow';
    
    const result = Result.succeed();
    // Result.Result<void, never>
    @seecollect - For collect multiple Results into a single Result.@seesequence - For sequence multiple Results into a single Result.@categoryCreators
    succeed
    ();
    // Result.Result<void, never>

    See

    • collect - For collect multiple Results into a single Result.
    • sequence - For sequence multiple Results into a single Result.

    Call Signature

    succeed(): Result<void, never>

    Returns

    Result<void, never>

    Call Signature

    succeed<T>(value): Result<T, never>

    Type Parameters

    T

    T

    Parameters

    value

    T

    Returns

    Result<T, never>