On GitHub, samber/mo has picked up 3.4k stars, Backend, Go. 🦄 Monads and popular FP abstractions, powered by Go 1.18+ Generics (Option, Result, Either...)
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
I cannot recommend it, but in case you are too lazy for repeating mo. everywhere, you can import the entire library into the namespace.
import (
. "github.com/samber/mo"
)
I take no responsibility on this junk. 😁 💩
🤠 Documentation and examples
GoDoc: https://godoc.org/github.com/samber/mo
Option[T any]
Option is a container for an optional value of type T. If value exists, Option is of type Some. If the value is absent, Option is of type None.
Implements:
mo.Foldable[T, U]
Constructors:
mo.Some() doc - play
mo.None() doc - play
mo.TupleToOption() doc - play
mo.EmptyableToOption() doc - play
mo.PointerToOption() doc - play
Methods:
.IsPresent() doc - play
.IsSome() doc - play
.IsAbsent() doc - play
.IsNone() doc - play
.Size() doc - play
.Get() doc - play
.MustGet() doc - play
.OrElse() doc - play
.OrEmpty() doc - play
.ToPointer() doc - play
.ForEach() doc
.Match() doc - play
.Map() doc - play
.MapNone() doc - play
.MapValue() doc
.FlatMap() doc - play
.MarshalJSON() doc
.UnmarshalJSON() doc
.MarshalText() doc
.UnmarshalText() doc
.MarshalBinary() doc
.UnmarshalBinary() doc
.GobEncode() doc
.GobDecode() doc
.Scan() doc
.Value() doc
Other:
mo.Fold[T, U, R any](f Foldable[T, U], successFunc func(U) R, failureFunc func(T) R) R doc
Sub-package option (transformations and pipes):
option.Map()() doc
option.FlatMap()() doc
option.Match()() doc
option.FlatMatch()() doc
option.Pipe1..Pipe10() docs
Result[T any]
Result respresent a result of an action having one of the following output: success or failure. An instance of Result is an instance of either Ok or Err. It could be compared to Either[error, T].
Implements:
mo.Foldable[T, U]
Constructors:
mo.Ok() doc - play
mo.Err() doc - play
mo.Errf() doc - play
mo.TupleToResult() doc - play
mo.Try() doc - play
Methods:
.IsOk() doc - play
.IsError() doc - play
.Error() doc - play
.Get() doc - play
.MustGet() doc - play
.OrElse() doc - play
.OrEmpty() doc - play
.ToEither() doc - play
.ForEach() doc - play
.Match() doc - play
.Map() doc - play
.MapValue() doc - play
.MapErr() doc - play
.FlatMap() doc - play
Other:
mo.Fold[T, U, R any](f Foldable[T, U], successFunc func(U) R, failureFunc func(T) R) R doc
Future represents a value which may or may not currently be available, but will be available at some point, or an exception if that value could not be made available.
Constructors:
mo.NewFuture() doc
Methods:
.Then() doc
.Catch() doc
.Finally() doc
.Collect() doc
.Result() doc
.Cancel() doc
IO[T any]
IO represents a non-deterministic synchronous computation that can cause side effects, yields a value of type R and never fails.
Constructors:
mo.NewIO() doc
mo.NewIO1() doc
mo.NewIO2() doc
mo.NewIO3() doc
mo.NewIO4() doc
mo.NewIO5() doc
Methods:
.Run() doc
IOEither[T any]
IO represents a non-deterministic synchronous computation that can cause side effects, yields a value of type R and can fail.
Constructors:
mo.NewIOEither() doc
mo.NewIOEither1() doc
mo.NewIOEither2() doc
mo.NewIOEither3() doc
mo.NewIOEither4() doc
mo.NewIOEither5() doc
Methods:
.Run() doc
Task[T any]
Task represents a non-deterministic asynchronous computation that can cause side effects, yields a value of type R and never fails.
Constructors:
mo.NewTask() doc
mo.NewTask1() doc
mo.NewTask2() doc
mo.NewTask3() doc
mo.NewTask4() doc
mo.NewTask5() doc
mo.NewTaskFromIO() doc
mo.NewTaskFromIO1() doc
mo.NewTaskFromIO2() doc
mo.NewTaskFromIO3() doc
mo.NewTaskFromIO4() doc
mo.NewTaskFromIO5() doc
Methods:
.Run() doc
TaskEither[T any]
TaskEither represents a non-deterministic asynchronous computation that can cause side effects, yields a value of type R and can fail.
Constructors:
mo.NewTaskEither() doc
mo.NewTaskEitherFromIOEither() doc
Methods:
.Run() doc
.OrElse() doc
.Match() doc
.TryCatch() doc
.ToTask() doc
.ToEither() doc
State[S any, A any]
State represents a function (S) -> (A, S), where S is state, A is result.
Constructors:
mo.NewState() doc
mo.ReturnState() doc
Methods:
.Run() doc
.Get() doc
.Modify() doc
.Put() doc
Foldable[T, U]
Foldable represents a type that can be folded into a single value based on its state.
mo.Fold[T, U, R any](f Foldable[T, U], successFunc func(U) R, failureFunc func(T) R) R doc
🛩 Benchmark
// @TODO
This library does not use reflect package. We don't expect overhead.
🤝 Contributing
Ping me on Twitter @samuelberthe (DMs, mentions, whatever :))
Fork the project
Fix open issues or request new features
Don't hesitate ;)
# Install some dev dependencies
make tools
# Run tests
make test
# or
make watch-test
The most recent commit recorded on samber/mo was 3 months ago, based on the GitHub push timestamp. The repository has 123 forks — one of the better signals of community interest.
How many stars does samber/mo have?
samber/mo has 3.4k GitHub stars — refresh the page for the live number, or check github.com/samber/mo. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What else is in the Backend space?
samber/mo is tracked by TopGit under the Backend category, alongside 19 GitHub-tagged topics. Trending and Topics pages list peer repositories of comparable stars and language.
What language is samber/mo written in?
samber/mo is written primarily in Go. GitHub's language field is based on the largest share of bytes in the default branch.
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/samber/mo is the definitive source.
Why is samber/mo categorized under Backend?
TopGit places samber/mo in the Backend category based on its GitHub topics and description (tagged: "cats", "either", "fp"). Categories are assigned from real repository metadata, not editorial guesswork.
Read full README in the tab above.
Still deciding about mo?
One click hands the question to an AI along with this page — see what it says about mo.