Created
January 4, 2025 11:56
-
-
Save joncol/d8dc03e08d998c6b85b6c31dce80aa8d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main :: IO () | |
main = do | |
evalContT $ do | |
a <- ContT $ withFile "a.txt" ReadMode | |
b <- ContT $ withFile "b.txt" ReadMode | |
aContents <- liftIO $ hGetContents a | |
bContents <- liftIO $ hGetContents b | |
liftIO . putStrLn $ "contents of a: " <> show aContents | |
liftIO . putStrLn $ "contents of b: " <> show bContents |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When the file
a.txt
exists, but the fileb.txt
does not exist, the following error is reported when running the above:It would be less confusing if that error said that
b.txt
did not exists, instead of complaining abouta.txt
. What am I missing?