Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Go
  3. fp-go

fp-go

MITGov0.11.1

A collection of functional programming helpers for Go, leveraging generics to provide common utilities like map, filter, reduce, and monadic types.

Visit WebsiteGitHubGitHub
325 stars10 forks0 contributors

What is fp-go?

fp-go is a functional programming library for Go that provides a collection of utilities like map, filter, reduce, and monadic types such as Option and Either. It leverages Go 1.18+ generics to offer type-safe operations, enabling developers to write more declarative and composable code in a language traditionally focused on imperative styles.

Target Audience

Go developers interested in functional programming patterns, those looking to write more declarative and composable code, and teams adopting generics for type-safe abstractions.

Value Proposition

It offers a pragmatic, idiomatic way to use functional programming in Go with automatic currying, flexible callback variations, and monadic types, reducing boilerplate and improving code expressiveness compared to manual implementations.

Overview

fp-go is a collection of Functional Programming helpers powered by Golang 1.18+ generics.

Use Cases

Best For

  • Writing declarative data transformations on slices in Go
  • Implementing functional patterns like currying and composition in Go projects
  • Handling optional values and errors with Option and Either types
  • Adopting functional programming idioms in a Go codebase
  • Reducing boilerplate in collection operations with type-safe generics
  • Chaining multiple operations cleanly using Pipe and Compose

Not Ideal For

  • Projects requiring compatibility with Go versions prior to 1.18, as fp-go depends on generics
  • Teams that prioritize minimal abstraction and prefer Go's native imperative loops for performance-critical code
  • Developers deeply invested in Go's standard error handling who would find monadic types like Either redundant or disruptive

Pros & Cons

Pros

Automatic Currying

Functions are curried by default with data-last parameters, enabling partial application and composition without extra setup, as shown in the Filter example where filterPositive is created by currying.

Flexible Callback Variations

Offers default, WithIndex, and WithSlice variants for helpers like Map and Filter, providing access to index and full slice when needed, which enhances adaptability for complex operations.

Type-Safe Generics

Leverages Go 1.18+ generics to ensure compile-time type safety in operations like Map and Reduce, reducing runtime errors compared to older interface-based approaches.

Monadic Error Handling

Implements Option and Either types for handling optional values and errors functionally, offering a declarative alternative to Go's traditional error patterns with methods like Match and GetOrElse.

Cons

Generics Dependency

Requires Go 1.18+ generics, making it incompatible with older Go versions or projects stuck in legacy environments, which limits adoption in certain codebases.

Performance Overhead

The functional abstractions, such as currying and monadic wrappers, can introduce additional function calls and allocations, potentially slowing down performance-critical loops compared to direct imperative code.

Limited Advanced Features

Compared to comprehensive FP libraries in other languages, it lacks advanced constructs like functors, applicatives, or monad transformers, which might be necessary for complex functional programming scenarios.

Frequently Asked Questions

Quick Stats

Stars325
Forks10
Contributors0
Open Issues1
Last commit3 years ago
CreatedSince 2022

Tags

#compose#functional-programming#either-type#pipe#currying#go-library#option#golang#type-safe#generics#collection-helpers#option-type#go#functional

Built With

G
Go

Links & Resources

Website

Included in

Go169.1k
Auto-fetched 2 hours ago

Related Projects

momo

🦄 Monads and popular FP abstractions, powered by Go 1.18+ Generics (Option, Result, Either...)

Stars3,380
Forks114
Last commit8 hours ago
go-underscorego-underscore

Helpfully Functional Go - A useful collection of Go utilities. Designed for programmer happiness.

Stars1,298
Forks62
Last commit3 years ago
go-functionalgo-functional

go-functional is a library of iterators to augment the standard library

Stars535
Forks26
Last commit8 days ago
fpGofpGo

Monad, Functional Programming features for Golang

Stars354
Forks22
Last commit15 hours ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub