[Haskell-cafe] Doubting Haskell
jonathanccast at fastmail.fm
Sun Feb 17 02:50:47 EST 2008
On 16 Feb 2008, at 11:46 PM, Anton van Straaten wrote:
> Colin Paul Adams wrote:
>>>>>>> "Cale" == Cale Gibbard <cgibbard at gmail.com> 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?
Standardization. It's already a standard, we need a standard sum
type anyway, and it'd be kind of silly to have two isomorphic types
with the same signature in the Prelude.
More information about the Haskell-Cafe