Skip to content

[feature]: Add Abort.ignore #1385

@steinybot

Description

@steinybot

Problem Statement

There are some cases where you want to use Abort for short circuit but you don't really care about the failure.

An example that came up in #1378 (comment) is:

    private def emitElementsFromChannel[V](channel: Channel[V])(using Tag[Emit[Chunk[V]]], Frame) =
        val emit = Loop.forever:
            channel.take.map: v =>
                Abort.recover[Closed](_ => Chunk.empty)(channel.drain).map: chunk =>
                    val fullChunk = Chunk(v).concat(chunk)
                    Emit.value(fullChunk)
        Abort.run[Closed](emit).unit
    end emitElementsFromChannel

In that case we don't care about the failure or success.

Proposed Solution

Something like:

Abort.ignore[Closed]

which returns Unit < (S & reduce.SReduced)

Alternative Solutions

No response

Current Workaround

The workaround is not very bad at all so this is only a very minor improvement:

Abort.run[Closed](emit).unit

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions