Được TopGit lập chỉ mục từ metadata GitHub: samber/mo có 3.4k sao, viết chủ yếu bằng Go. 🦄 Monads and popular FP abstractions, powered by Go 1.18+ Generics (Option, Result, Either...)
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
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
samber/mo thuộc nhóm Backend trên TopGit, cùng 19 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về samber/mo ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/samber/mo là nguồn chính thức.
samber/mo có bao nhiêu sao?
samber/mo có 3.4k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/samber/mo. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
Commit gần nhất trên samber/mo là 3 tháng trước (theo timestamp GitHub). Repo có 123 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
samber/mo viết bằng ngôn ngữ gì?
samber/mo chủ yếu viết bằng Go. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Vì sao samber/mo được xếp vào nhóm Backend?
TopGit xếp samber/mo vào nhóm Backend dựa trên GitHub topics và mô tả của repo (gắn thẻ: "cats", "either", "fp"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
mo có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về mo.