fp-go
Installation
SKILL.md
fp-go v2 — Functional Programming for Go
Critical Rules for Code Generation
- Import path is v2: always
github.com/IBM/fp-go/v2/..., nevergithub.com/IBM/fp-go/...(that is v1). - Data-last: all operations return a function waiting for data. Write
option.Map(f)(value), neveroption.Map(value, f). - Non-inferrable type parameters come first:
Map[B, A],Ap[B, A],Chain[B, A]. The compiler infers trailing params from arguments; leading params often need explicit annotation. - Prefer
ResultoverEitherwhen the error type is Go'serror.Result[A]isEither[error, A]. Same forioresultoverioeither,readerioresultoverreaderioeither. - IO values are lazy:
IO[A]isfunc() A. They describe a computation — you must call()to execute. Don't forget the trailing(). - Prefer point-free style: compose with
F.FlowandF.Pipeinstead of writing inline anonymous functions. If a transformation can be expressed as a composition of named functions, it should be. Point-free pipelines are idiomatic fp-go.
Generation Workflow
Two habits that matter more for fp-go than for idiomatic Go, because the library is low-frequency in training data and easy to misremember:
- Retrieve before generating. For any pattern not fully covered below — optics beyond simple lenses, traversals, concurrent combinators, the less-common monads — query the fp-go MCP server's
search_examples/get_exampletools (see the fp-go-mcp skill) for a real signature instead of recalling names likeChain/FlatMap/Bindfrom memory. Retrieve-then-generate beats generate-then-fix here. - Compile before presenting. After writing fp-go code, run
go build ./...andgo vet ./..., then fix any import, type-parameter, or argument-order error and re-run until clean. The compiler is precise, low-ambiguity feedback, and most fp-go mistakes (wrong leading type param, data-first vs data-last) surface immediately.