Return
True if the given value is a
Left-value,
False otherwise.
Examples
Basic usage:
>>> isLeft (Left "foo")
True
>>> isLeft (Right 3)
False
Assuming a
Left value signifies some sort of error, we can use
isLeft to write a very simple error-reporting function that
does absolutely nothing in the case of success, and outputs "ERROR" if
any error occurred.
This example shows how
isLeft might be used to avoid pattern
matching when one does not care about the value contained in the
constructor:
>>> import Control.Monad ( when )
>>> let report e = when (isLeft e) $ putStrLn "ERROR"
>>> report (Right 1)
>>> report (Left "parse error")
ERROR