You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
kcmvp
changed the title
Feature Request: (Or How) about call a method on Foldable when "T", "U" inherit from same interface
Feature Request: (or How-To) about call a method on Foldable when "T", "U" inherit from same interface
Jul 8, 2024
1: in either case(case1, case2) the logic should be the same, as *types.Interface and *types.Named may inherit from same interface type.TypeSet (explict or implict) So In my case I hope there is just one function as parameter as below
Fold[T, U, R any](f Foldable[T, U], process func(ts type.TypeSet) string) string
T -> *types.Interface
U -> *types.Named
just as I high-light in red, some times this method return nothing just do some side effect.
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.
The text was updated successfully, but these errors were encountered: