We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 331371e commit 123c169Copy full SHA for 123c169
snippets/haskell/file-handling/file-exists.md
@@ -0,0 +1,19 @@
1
+---
2
+title: Check if File Exists
3
+description: Checks if a file exists at a given path.
4
+author: ACR1209
5
+tags: haskell,file,exists
6
7
+
8
+```hs
9
+import System.Directory (doesFileExist)
10
11
+checkFileExists :: FilePath -> IO Bool
12
+checkFileExists = doesFileExist
13
14
+main :: IO ()
15
+main = do
16
+ let file = "example.txt"
17
+ exists <- checkFileExists file
18
+ if exists then putStrLn "File exists." else putStrLn "File does not exist."
19
+```
0 commit comments