Free preview.You're sampling one lesson — enroll free to unlock all 8 lessons and track your progress.
Enroll free lesson
Concurrency vs. Parallelism
Concurrency vs. Parallelism
In this lesson — part of Concurrency Basics — you'll learn concurrency vs. parallelism in Haskell and why it matters in real work.
Why it matters
Modern programs wait on networks and disks — async lets them stay responsive.
Key ideas
- Blocking vs. non-blocking
- Callbacks, promises, async/await
- Concurrency vs. parallelism
- Error handling in async code
In practice
Here's how it looks in idiomatic Haskell:
import Control.Concurrent.Async (concurrently)
fetch :: String -> IO Int
fetch url = pure (length url) -- stand-in for real IO
main :: IO ()
main = do
(a, b) <- concurrently (fetch "x") (fetch "yy") -- run both, await both
print (a + b)
Haskell note: The async library builds on lightweight green threads, so spawning thousands of concurrent IO actions is cheap, and concurrently propagates exceptions and cancellation between the linked threads.
Try it yourself
Exercise: In Haskell, fetch two things concurrently and combine the results.
Recap
You now understand concurrency vs. parallelism and can apply it in Haskell. Mark this lesson complete and continue to the next one.
