diff options
| author | Jan Sucan <jan@jansucan.com> | 2023-02-05 18:02:37 +0100 |
|---|---|---|
| committer | Jan Sucan <jan@jansucan.com> | 2023-03-06 10:36:09 +0100 |
| commit | 1c53f0bf4bf65af0c3d0dd1145cda38f0f2cab0c (patch) | |
| tree | aba338d3daf051ce888588cea7525e47dc637b7b | |
Initial commit
| -rw-r--r-- | .gitmodules | 3 | ||||
| -rw-r--r-- | README.md | 140 | ||||
| m--------- | examples | 0 |
3 files changed, 143 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5ec7695 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "examples"] + path = examples + url = https://resources.oreilly.com/examples/9780596514983 diff --git a/README.md b/README.md new file mode 100644 index 0000000..4f6483a --- /dev/null +++ b/README.md @@ -0,0 +1,140 @@ +# Real World Haskell solutions + +These are solutions to exercises from me reading the first edition of the [the +Real World Haskell book](https://book.realworldhaskell.org/). I hope they will +be helpful in your journey to the world of Haskell. + +The goal is to provide solutions to all the exercises. I'm adding them gradually +as I'm progressing through the book. + +There is often more than one solution to an exercise. If your solution is +different but meets the assignment, it is the right one. + +The intention is for the exercises to be solved as by a beginner, with all the +things that a seasoned Haskell programmer would have done differently. Where +possible, the solutions should use only knowledge from the preceding parts of +the book. + +## Exercises + +There are a few kinds of exercises: + +- Describe what happens when you run the code +- Answer a question +- Write an implementation + +Solutions to the first two kinds of exercises are provided in comments. + +Some exercises are not unambiguous. In these cases I describe my additional +assumptions and thought process in comments. + +Some solution implementations depend on [the example code from the +book](https://resources.oreilly.com/examples/9780596514983). The complete +examples repository these solutions are base on is added as a submodule in the +'examples' directory. If a solution of an exercise depends on source files from +the examples, those files are copied to a directory of that solution. + +Here is a list of the exercises. Format of an exercise label is +'\<chapter\>\_\<group\>\_\<exercise\>'. Some chapters contain more groups of +exercises. To differentiate those, an exercises group letter is included (the +exact letters don't have a connection to the book). To make the exercise groups +more visible in the list the first exercise of a group is in bold italics. + + +| Exercise | Solved | Page | Chapter | +| -------------- | ------ | ---- | ------- | +| **_1_a_1_** | | 16 | 1. Getting started | +| 1_a_2 | | | | +| 1_a_3 | | | | +| 1_a_4 | | | | +| **_2_a_1_** | | 25 | 2. Types and functions | +| **_2_b_1_** | | 39 | | +| 2_b_2 | | | | +| 2_b_3 | | | | +| **_3_a_1_** | | 60 | 3. Defining types, streamlining functions | +| 3_a_2 | | | | +| **_3_b_1_** | | 69 | | +| 3_b_2 | | | | +| 3_b_3 | | | | +| 3_b_4 | | | | +| 3_b_5 | | | | +| 3_b_6 | | 70 | | +| 3_b_7 | | | | +| 3_b_8 | | | | +| 3_b_9 | | | | +| 3_b_10 | | | | +| 3_b_11 | | | | +| 3_b_12 | | | | +| **_4_a_1_** | | 84 | 4. Functional programming | +| 4_a_2 | | | | +| 4_a_3 | | | | +| 4_a_4 | | | | +| **_4_b_1_** | | 97 | | +| 4_b_2 | | 98 | | +| 4_b_3 | | | | +| 4_b_4 | | | | +| 4_b_5 | | | | +| 4_b_6 | | | | +| 4_b_7 | | | | +| 4_b_8 | | | | +| 4_b_9 | | | | +| 4_b_10 | | | | +| **_5_a_1_** | | 130 | 5. Writing a library: working with JSON data | +| 5_a_2 | | | | +| **_6_a_1_** | | 162 | 6. Using typeclasses | +| 6_a_2 | | | | +| **_8_a_1_** | | 205 | 8. Efficient file processing, regular expressions, and file name matching | +| 8_a_2 | | | | +| **_8_b_1_** | | 210 | | +| 8_b_2 | | | | +| 8_b_3 | | | | +| **_8_b_1_** | | 211 | | +| 8_b_2 | | | | +| **_8_d_1_** | | 212 | | +| **_9_a_1_** | | 221 | 9. I/O case study: a library for searching the filesystem | +| **_9_b_1_** | | 228 | | +| 9_b_2 | | | | +| 9_b_3 | | | | +| 9_b_4 | | | | +| **_9_c_1_** | | 232 | | +| 9_c_2 | | | | +| 9_c_3 | | | | +| **_9_d_1_** | | 234 | | +| 9_d_2 | | | | +| **_10_a_1_** | | 254 | 10. Code case study: parsing a binary data format | +| 10_a_2 | | | | +| 10_a_3 | | | | +| **_12_a_1_** | | 274 | 12. Barcode recognition | +| 12_a_2 | | | | +| 12_a_3 | | | | +| **_13_a_1_** | | 316 | 13. Data structures | +| **_14_a_1_** | | 352 | 14. Monads | +| **_15_a_1_** | | 382 | 15. Programming with monads | +| 15_a_2 | | | | +| 15_a_3 | | | | +| **_16_a_1_** | | 403 | 16. The Parsec parsing library | +| 16_a_2 | | | | +| 16_a_3 | | | | +| 16_a_4 | | | | +| **_18_a_1_** | | 436 | 18. Monad transformers | +| 18_a_2 | | | | +| 18_a_3 | | | | +| **_18_b_1_** | | 441 | | +| **_19_a_1_** | | 462 | 19. Error handling | +| **_19_b_1_** | | 465 | | +| 19_b_2 | | | | +| 19_b_3 | | | | +| **_23_a_1_** | | 529 | 23. GUI programming | +| 23_a_2 | | | | +| 23_a_3 | | | | +| **_24_a_1_** | | 542 | 24. Basic concurrent and parallel programming | +| 24_a_2 | | | | +| **_24_b_1_** | | 551 | | +| 24_b_2 | | | | +| **_26_a_1_** | | 610 | 26. Advanced library design: building a Bloom filter | +| 26_a_2 | | | | + +## Bug reports + +If you find an error in a solution or anything that should be described more +clearly, feel free to let me know. diff --git a/examples b/examples new file mode 160000 +Subproject a49fbacd3c5c0a5381ee6545175368eb63f7223 |
