Skip to content

Feature Request: (or How-To) about call a method on Foldable when "T", "U" inherit from same interface #48

Open
@kcmvp

Description

type Foldable[T any, U any] interface { leftValue() T rightValue() U hasLeftValue() bool }

here is the my case:
1: I build a mo.Either base on a if/else, saying Either[A,B], A and B implement same interface C
2: I build a Foldable from the either. but I want to execute same function on the foldable.

right now the API must pass in two method "successFunc" and "failureFunc", for the case i describe seems redundant

by the way, of course, I can use case assert cast A or B to C. and then call the method.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions