Effect CommunityEC
Effect Community3y ago
23 replies
wayne

Overloading Functions with Refinements

I've found a number of functions that take predicates, but that I think could also be overloaded with refinements. Not having refinements means I'm having to make ugly type assertions, e.g.:
    const [formFieldsChunk, leftoverParts] = yield* _(
        Stream.peel(
            stream,
            // collectAllWhile doesn't take a Refinement :-|
            Sink.collectAllWhile((a): a is Field => a._tag === 'Field'),
        ),
        a =>
            a as Effect.Effect<
                Scope.Scope,
                never,
                readonly [Chunk.Chunk<Field>, Stream.Stream<never, never, Part>]
            >,
    );

Was there some intention behind this, or can I starting making some PRs when I find this?
Was this page helpful?