16. Why prefer Data.Text over String in real applications?
- String does not support Unicode
- Text is required by GHC
- Text is a compact, efficient representation, while String is a linked list of characters
- String cannot be printed
Show answer
Answer: Text is a compact, efficient representation, while String is a linked list of characters
String is [Char], which is slow and memory-hungry for large text.
Lesson: Modules, Packages, Text and Containers
18. What does retry do inside an STM transaction?
- Aborts the transaction and blocks until one of the TVars it read changes
- Retries immediately in a busy loop
- Throws an exception
- Commits partially
Show answer
Answer: Aborts the transaction and blocks until one of the TVars it read changes
retry waits for relevant state to change before re-running the transaction.
Lesson: Concurrency: Threads, MVar, STM and async