samber / samber/mo

Add Helper function that would work like Either.Match but would return another type

Open
#6 4 comments 4 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

Could we have a helper function like the following for Either?

func Map[T any](e Either[L, R], onLeft func(L) T, onRight func(R) T) T 

It would be useful to be able to Map an Either to another type.

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 by reading the existing Either.Match implementation and its surrounding tests or usage examples. Add the requested mapping behavior so both Either branches return a value of the target type, then verify that the behavior matches the proposed signature for left and right values.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend-api-design
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.