/fp-in-go

Functional programming in Go

Primary LanguageGo

fp-in-go

Functional programming in Go

Benefits of FP

  1. Local reasoning
  2. Combinability
  3. Easier testing
  4. Robust systems
  5. "Programs are written at a higher level, and are therefore easier to comprehend"
  6. "Parallel/concurrent programming is easier"

See more details from Alvin Alexander

Enablers of FP

  1. Side effect free code
  2. Immutable data
  3. Transformation of data instead of step by step refinement
  4. Category theory

Most convenient style of FP

  1. Recursion
  2. Builtin special for loops: Map, FlatMap, Filter, Fold, Unfold
  3. Collection methods: Head, Tail, Take, Drop, Partition
  4. Pattern matching

Short introduction for some exiting concepts

Explanations of Lenses

For TypeScript: https://medium.com/@gcanti/introduction-to-optics-lenses-and-prisms-3230e73bfcfe

For Haskell: https://en.wikibooks.org/wiki/Haskell/Lenses_and_functional_references and https://www.schoolofhaskell.com/school/to-infinity-and-beyond/pick-of-the-week/basic-lensing

For Scala: https://medium.com/zyseme-technology/functional-references-lens-and-other-optics-in-scala-e5f7e2fdafe