Concurrency in Haskell with Streamly
summary
Claims a practical recipe for fast, reliable concurrency in Haskell using Streamly streams plus MVars, TVars, STM and ReaderT IO, shows code on GitHub and slides, demonstrates how async/link propagates exceptions, how STM retry prevents invalid updates, and how producer/consumer patterns avoid MVar deadlocks. Examples include merging concurrent API calls (Hacker News) with parallel maps and converting between streams and TVars; the implemented examples run and expose where race conditions or livelock can still occur.
AI-written summary · about
chapters (33)
- 0:00Intro
- 2:11Concurrency & parallelism: definitions
- 3:43Concurrency & parallelism: basics
- 4:38Scope of the talk
- 6:12Terminology
- 10:02Example of why sharing is hard
- 12:21Solutions to race conditions non-exhaustive Don't just read and write RAM Wily nily in a multi-threaded program
- 14:02How does Haskell's purity prevent race condit
- 14:29Limitations of pure code for concurrency
- 15:04Haskell threads
- 16:06Async (a thin abstraction over threads)
- 16:32Exception propagation using async
- 17:04Three tools for architecting the impure parts of concurrent Haskell program
- 17:54MVar mutual exclusion of reading and writing
- 18:14Reading an MVar
- 19:11Writing to an MVar
- 21:26Deadlocks, synchronization, and MVars
- 22:02Examples of MVar deadlocks
- 22:54When is MVar code deadlock-free?
- 23:41What happens when MVar code has deadlock
- 25:55Practical applications
- 29:18Software transactional memory vs. MVars
- 30:20Deadlocks and race conditions using STM
- 31:10STM example
- 33:05TVar race condition example
- 33:56Using TVars for synchronization
- 36:58Types of streams
- 38:13Stream types
- 40:13Creating a stream using an MVar
- 41:19Creating a TVar using a stream
- 42:23Creating a stream using a TVar
- 43:01Circular dependencies: streams, MVars, and
- 45:25Limitations & possible solutions
related talks
38mAccidentally Concurrent
32mPRACTICAL REACTIVE STREAMS WITH MONIX
42mLearn you Akka Streams for great Good!
27mAsync/Await: Thinking beyond Combine
48mAsynchronous streams in direct style with and without macros
46mStreams, effects and beautiful folds, a winning trilogy
25mFunctional effect and streaming systems in Clojure
38mConcurrency doesn,t have to be hard: Kotlin Coroutines and Channels
