📦 fp-go/ IBM
Functional programming library for Go 1.24+, inspired by fp-ts. Uses generic type aliases for a clean, composable API. Provides Option, Either, Result, IO, IOResult, Reader, and ReaderIOResult monads, plus optics (Lens, Prism, Traversal) for immutable data manipulation. Supports Functor, Applicative, and Monad abstractions with do-notation-style
Открыть на GitHub ↗обновлён 4д назад
Звёзды
★ 2.0k
Форки
80
За неделю
—
За месяц
—
Рост %
—
Язык
Go
Установка и запуск
Installation
go get github.com/IBM/fp-go
Example: Chaining Operations
import (
"github.com/IBM/fp-go/either"
"github.com/IBM/fp-go/function"
)
result := function.Pipe3(
either.Right[error](10),
either.Map(func(x int) int { return x * 2 }),
either.Chain(func(x int) either.Either[error, int] {
if x > 15 {
return either.Right[error](x)
}
return either.Left[int](errors.New("too small"))
}),
either.GetOrElse(func() int { return 0 }),
)
Из README репозитория · полный README на GitHub
Категории
Теги
functional-programminggogolanglibrarymonadutility