Fun with Generics
summary
Shows a generic monads library built in Go that implements an Option type (sum/none) and compares an interface-based design with a struct-backed Option; methods with type parameters prove impossible so map is a standalone generic function, and none cannot be typeless. Implements lift helpers for 1–3-argument partial functions (lift1/lift2/lift3) to turn (T, error) returns into Option results; type inference mostly works, the implementation functions and examples run, but ergonomics and compiler support limit production readiness.
AI-written summary · about
chapters (18)
- 0:00Intro
- 1:42Disclaimer
- 4:21Example: package sort
- 6:17Anatomy of a generic type or function
- 6:41Naming conventions
- 7:14Type Constraints
- 12:06Monad: an overly simplified definition
- 12:45Our monad: Option type
- 14:02Application: Lifting partial functions
- 15:27Data Transformation Pipelines
- 16:43A simple API
- 17:30Design considerations
- 18:30Option as an interface
- 19:34Map as a standalone function
- 25:59Option as a struct
- 29:35Error Handling with Options
- 30:26Lifting Revisited
- 37:05References








