Skip to main content
Version: v2.2.82 (latest)
Concepts · Overview

Core concepts.

The functional programming ideas behind fp-go — six topics, taught from first principles with Go-specific examples.

// Foundations
Pure functions and composition.
// Patterns
Monads, effects, HKTs.
// Integration
How FP fits the Zen of Go.
01

The six topics.

TopicYou learnWhy it matters
Pure functionsDefinition, properties, benefits, pure vs impure in Go, practical examples
The foundation. Easier to test, reason about, compose.
MonadsWhat monads are (and aren't), the monad laws, Option/Either/Result/IO, usage patterns
A consistent way to handle effects, errors, optional values — without exceptions or nil checks.
CompositionFunction composition, Pipe and Flow, point-free style, pipelines
Build maintainable systems from small, focused functions.
Effects & IOWhat effects are, lazy evaluation, IO monad, Effect type, separating description from execution
Explicit effect management makes code predictable and testable.
Higher-kinded typesWhat HKTs are, why Go lacks them, how fp-go works around it, generic parameters
Helps you use fp-go's generic APIs effectively.
The Zen of GoSimplicity, explicit over implicit, composition, error handling, when to use fp-go
fp-go enhances Go — it doesn't replace it.
02

Learning paths.

For beginnersrecommended order

1. Pure functions — the basics.

2. Effects & IO — why special types are needed.

3. Composition — building pipelines.

4. Monads — the underlying pattern.

5. The Zen of Go — integrating with Go idioms.

For FP practitionersfrom other languages

1. Zen of Go — understand the constraints.

2. HKTs — see fp-go's approach.

3. Monads — Go-specific implementations.

4. Effects & IO — lazy evaluation in Go.

For Go developers new to FP.

Start with The Zen of GoPure functionsCompositionEffects & IOMonads.

03

Practical examples.

Each concept page includes a three-tab comparison: without fp-go, fp-go v2, fp-go v1.

processUser.go
// Standard Go approach
func processUser(id string) (*User, error) {
  user, err := fetchUser(id)
  if err != nil {
      return nil, err
  }

  validated, err := validateUser(user)
  if err != nil {
      return nil, err
  }

  return saveUser(validated)
}
Real-world scenarios covered.

HTTP API handlers · database operations · file processing · configuration management · error-handling patterns.

04

Common questions.

Isn't this overengineering?

Not if used appropriately. fp-go shines for complex error handling, multiple sequential operations, composability needs, and testing-heavy codebases. For simple cases, standard Go is often better — see The Zen of Go.

Will this make my code slower?

Usually no, sometimes yes. Pure functions are often faster (easier to optimize); composition has minimal overhead; IO types add one function call. Use idiomatic packages for performance-critical code.

How do I convince my team?

Start small, show value: use fp-go for new features, demonstrate improved testability and clearer error handling, share success stories, provide training. See Why fp-go?.

What if I don't understand monads?

You don't need to. Think: Option = "maybe has a value"; Result = "success or error"; IO = "lazy computation". The theory helps but isn't required.

05

Concept relationships.

map
Pure Functions
  ↓
Composition ←→ Effects & IO
  ↓              ↓
Monads ←──────────┘
  ↓
Higher-Kinded Types
  ↓
The Zen of Go
Flow.

Pure functions are composable → composition builds pipelines → effects need special handling → monads provide the pattern → HKTs enable generic implementations → the Zen of Go guides usage.

06

Prerequisites

RequiredGo basics

Basic Go syntax.

Functions and closures.

Interfaces.

Generics (Go 1.18+).

Recommendedreading

Go Tour — if new to Go.

Effective Go — best practices.

Quickstart — fp-go basics.

No FP experience needed.

These guides assume no prior functional programming knowledge. Concepts are taught from first principles with Go examples.

07

Summary

What you'll learn6 / 6 complete
  • Pure Functions — predictable, testable code
  • Monads — pattern for sequencing with context
  • Composition — building from simple pieces
  • Effects & IO — explicit side effect management
  • Higher-Kinded Types — generic abstractions
  • The Zen of Go — idiomatic usage
Key takeaway.

You don't need to understand all the theory to use fp-go effectively. Start with practical patterns and deepen your understanding over time.