Skip to main content
v2.2.82 · Stable release

Functional
programming
for Go.

A practical, generics-powered toolkit for writing typed, composable Go. Zero dependencies. Production ready.

2k
GitHub stars
50+
Contributors
95%
Test coverage
0
Dependencies
Capabilities

Functional primitives, built for the Go developer experience.

01

Fast & idiomatic

Generics-native. No reflection, no runtime cost. Feels like plain Go.

Learn more
02

Type-safe

Option, Either, Result, Try — full inference. Never interface{} again.

Learn more
03

Composable

Pipe, compose, fold. Build readable pipelines from one-screen functions.

Learn more
04

Battle-tested

Powers data pipelines at IBM and beyond. 95% coverage, fuzz-tested.

Learn more
Example

Write less. Express more.

Replace if err != nil ladders with typed flows. Compose small, total functions into pipelines that are easy to read, refactor, and test.

  • 01Option[T] — nullable values without nil checks.
  • 02Either[E,A] & Result[T] — typed error flows.
  • 03Pipe & Compose — left-to-right data transforms.
  • 04Slice & Map helpers: filter, fold, group, partition, zip.
main.go
option.go
pipe_test.go
fp-go · greet.go
package main

import (
    "fmt"
    "strings"
    F "github.com/IBM/fp-go/v2"
    O "github.com/IBM/fp-go/v2/option"
)

// Parse → validate → format. Total, typed, nil-safe.
func greet(raw string) string {
    return F.Pipe3(
        O.FromString(raw),
        O.Filter(func(s string) bool {
            return len(s) > 1
        }),
        O.Map(strings.Title),
        O.GetOrElse(F.Constant("friend")),
    )
}

func main() {
    fmt.Println("Hello, " + greet("ada"))
    // → Hello, Ada
}