Skip to content

Add a convenience for mapping outputs from Never to any type that does not produce compiler warnings #339

@jamieQ

Description

@jamieQ

today, attempting to do this both requires an instance of the new type and produces a compiler warning. we should offer a special case for this that makes the type signatures 'just work' without requiring a value and doesn't emit a compiler warning. example:

struct WF: Workflow {
    typealias Output = Never
    typealias State = Void
    typealias Rendering = Int

    func render(state: State, context: RenderContext<WF>) -> Rendering {

        return 0
    }
}

func test(_ rc: RenderContext<WF>) {
    enum NewOutput {
        case zero
    }

    let z: AnyWorkflow<String, NewOutput> = WF()
        .mapRendering { "\($0)" }
        .mapOutput { _ in .zero } // ⚠️ Will never be executed
        .asAnyWorkflow()

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions