~/talk

A roadtrip with monads: from MTL, through tagless, to BIO

Talkat Scalapeño 2018 · on Monday, 2018-07-02· [scala, functional-programming]
slides:none on file

A simple Scala weather client is implemented (console I/O, config, cache, third‑party HTTP client) using typeclass abstractions so every effect is abstracted behind an F. Code uses monad transformer stack originally (ReaderT/StateT/EitherT over Task), then swaps to typeclasses: ApplicativeAsk/ApplicativeError/MonadState plus custom Console and Weather traits. Tests become trivial by providing fake instances. Benchmarks show the transformer stack is ~an order of magnitude slower; replacing State with Atomic and providing custom instances brings performance near imperative, with a pathological Throwable‑only instance giving another ~2x.

AI-written summary · about

  1. 0:00Introduction to functional programming
  2. 1:02Why functional programming
  3. 2:46Functional programming basics
  4. 7:00Building a weather app
  5. 17:23The monad stack problem
  6. 19:09Monads do not compose
  7. 21:45Type classes to the rescue
  8. 26:42Error handling with type classes
  9. 27:49State and console abstractions
  10. 29:33Final program with constraints
  11. 31:18Performance of monad stacks
  12. 33:25Tagless final approach
  13. 34:53BIO for better performance
  14. 35:35Removing the error type
  15. 37:02Conclusion and next steps
~/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.