~/talk

Fun with Generics

Talkat GopherCon UK 2023 · 2023-08-16..08-18· [go]
slides:none on file

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

  1. 0:00Intro
  2. 1:42Disclaimer
  3. 4:21Example: package sort
  4. 6:17Anatomy of a generic type or function
  5. 6:41Naming conventions
  6. 7:14Type Constraints
  7. 12:06Monad: an overly simplified definition
  8. 12:45Our monad: Option type
  9. 14:02Application: Lifting partial functions
  10. 15:27Data Transformation Pipelines
  11. 16:43A simple API
  12. 17:30Design considerations
  13. 18:30Option as an interface
  14. 19:34Map as a standalone function
  15. 25:59Option as a struct
  16. 29:35Error Handling with Options
  17. 30:26Lifting Revisited
  18. 37:05References
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.