[Haskell-cafe] Doubting Haskell

Derek Elkins derek.a.elkins at gmail.com
Sun Feb 17 02:38:30 EST 2008

On Sun, 2008-02-17 at 02:46 -0500, 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.

Actually, it's either intentional or ironic that Colin uses the word
"sinister" in his response as "Left" is etymologically related to it.
http://en.wikipedia.org/wiki/Left-handed#Negative_associations_of_left-handedness_in_language (to the extent wikipedia can be trusted)
Indeed, also as wikipedia mentions, there are entire connotations with
both words along the lines of how Haskell libraries use them.

The benefit of reusing Either is that a) it -is- already mnemonic, b)
there are several functions that operate on Eithers in the standard,
there's little point in rewriting all of them just so you can say Ok or

That said, you often don't see too many explicit uses of the
constructors of Either (as functions or patterns) in Haskell code as it
is usually more convenient to use combinators (e.g. either or the monad
methods) rather than explicit cases.

More information about the Haskell-Cafe mailing list