Converting Pipes with `filterOrFail` to Generators in Typescript

I'm trying to convert my pipes to generators, what's the best way to convert the filterOrFail parts into a generator?

const fn = (content : string) =>
    Effect.succeed(content).pipe(
        Effect.filterOrFail((content) => content.length > 5, messagise(TooShort)),
        Effect.filterOrFail((str) => str.length < 350, messagise(TooLong)),
        Effect.flatMap((content) =>
            fetchAIData([
                {
                    role: 'system',
                    content: STATEMENT_LIST
                },
                {
                    role: 'user',
                    content
                }
            ])
        ),
        Effect.flatMap(parseAIJSONResponseContent),
        Effect.flatMap(Schema.validate(EncodedList))
Was this page helpful?