
Colin Paul Adams wrote:
"Cale" == Cale Gibbard
writes: Cale> So, the first version:
Cale> import System.IO import Control.Exception (try)
Cale> main = do mfh <- try (openFile "myFile" ReadMode) case mfh Cale> of Left err -> do putStr "Error opening file for reading: " Cale> print err Right fh -> do mline <- try (hGetLine fh) case Cale> mline of Left err -> do putStr "Error reading line: " print Cale> err hClose fh Right line -> putStrLn ("Read: " ++ line)
Left? Right?
Hardly descriptive terms. Sounds like a sinister language to me.
I was thinking along the same lines. Politically-sensitive left-handed people everywhere ought to be offended that "Left" is the alternative used to represent errors, mnemonic value notwithstanding. Is there a benefit to reusing a generic Either type for this sort of thing? For code comprehensibility, wouldn't it be better to use more specific names? If I want car and cdr, I know where to find it. Anton