When to Use Yield Effect Wrapping in Generators

When should I use the yield effect wrapping in generators? (The _ or $).

The following code looks to work correctly despite the lack of yield* _(Effect..)
const createAuthorizationURL = (clientInfo: ClientInfo, options?: Options) => Effect.gen(function* (_) {
    const scopes = new Set(options?.scopes); // remove duplicates
    const authorizationUrl = yield* Effect.try({
        try: () => new URL(clientInfo.authorizeEndpoint),
        catch: () => new Cause.IllegalArgumentException(`Failed to create authorization URL: "${clientInfo.authorizeEndpoint}" is not a valid URL.`)
    });

    return authorizationUrl;
});
Was this page helpful?