export function success(value) {
    return { success: true, value };
}
export function failure(error) {
    return { success: false, error };
}
export function mergeResults(results) {
    const values = [];
    const failures = [];
    for (const result of results) {
        if (!result.success) {
            failures.push(result.error);
        }
        else {
            values.push(result.value);
        }
    }
    if (failures.length > 0) {
        return failure(failures.join(", "));
    }
    return success(values);
}
export function resultMap(result, fn) {
    if (result.success) {
        return success(fn(result.value));
    }
    else {
        return result;
    }
}
