samber / samber/mo

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

Open
#48 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
3.4k
Forks
120
Avg merge
4d 17h
Merged PRs (30d)
3

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Foldable[T,U] interface and the mo.Either API described in the issue, then inspect how the successFunc and failureFunc callbacks are currently used. Determine whether supporting one callback for values sharing interface C is intended as an API change or a how-to clarification; the issue names no files or tests, so the expected behavior needs agreement before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.