aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Sucan <jan@jansucan.com>2023-06-18 18:06:19 +0200
committerJan Sucan <jan@jansucan.com>2023-06-18 18:06:19 +0200
commitd678bfd90f483ca9d000c267ee9f883de89feeaf (patch)
treeadab6b3a8116a6fdac3a6f757b3113fa6c825ce2
parentf4370aea1a865a3c5be7759702292fa559b887d6 (diff)
8_b_2: Add solution
-rw-r--r--README.md2
-rw-r--r--ch08/8_b_2.txt19
2 files changed, 20 insertions, 1 deletions
diff --git a/README.md b/README.md
index 525f19a..90b1ca4 100644
--- a/README.md
+++ b/README.md
@@ -109,7 +109,7 @@ of a group is in bold italics.
| **_8_a_1_** | yes | 205 | 8. Efficient file processing, regular expressions, and file name matching |
| 8_a_2 | yes | | |
| **_8_b_1_** | yes, in 8_a_2 | 210 | |
-| 8_b_2 | | | |
+| 8_b_2 | yes | | |
| 8_b_3 | | | |
| **_8_b_1_** | | 211 | |
| 8_b_2 | | | |
diff --git a/ch08/8_b_2.txt b/ch08/8_b_2.txt
new file mode 100644
index 0000000..6af6518
--- /dev/null
+++ b/ch08/8_b_2.txt
@@ -0,0 +1,19 @@
+-- If you're on a Unix-like system, look through the documentation for the
+-- System.Posix.Files module, and see if you can find a replacement for the
+-- doesNameExist function.
+
+-- The replacement is the fileExist function that checks for existence of both
+-- regular file and directories.
+
+ghci> :module + System.Posix.Files
+
+ghci> fileExist "nonexistent_file"
+False
+
+-- Regular file
+ghci> fileExist "8_b_2.txt"
+True
+
+-- Directory
+ghci> fileExist "../ch08/"
+True