[Haskell-cafe] Doubting Haskell

Thomas Schilling nominolo at googlemail.com
Sun Feb 17 05:15:25 EST 2008

On 17 feb 2008, at 08.46, 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?  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.

Haskell doesn't have constructor aliases and keeping around dozens of  
isomorphic types would be stupid.  (Views could help, though.)

Also, "Right" is naturally used when the everything was alright.  It  
might be arbitrary, but it's not hard to remember - once you're past  
the newbie phase no-one confuses car and cdr anyways...

More information about the Haskell-Cafe mailing list