Check that file exists: Difference between revisions

Content added Content deleted
m (→‎{{header|Haskell}}: Specified imports, applied hlint, hindent)
Line 1,007: Line 1,007:
=={{header|Haskell}}==
=={{header|Haskell}}==


<lang haskell>import System.IO
<lang haskell>import System.Directory (doesFileExist, doesDirectoryExist)
import System.Directory


check :: (FilePath -> IO Bool) -> FilePath -> IO ()
check :: (FilePath -> IO Bool) -> FilePath -> IO ()
check p s = do
check p s = do
result <- p s
result <- p s
putStrLn $
putStrLn $ s ++ if result then " does exist" else " does not exist"
s ++
if result
then " does exist"
else " does not exist"


main :: IO ()
main = do
main = do
check doesFileExist "input.txt"
check doesFileExist "input.txt"