Commit 48fde4bd authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Add isLeft from Data.Either explicitly



...as it is only included in newer Versions of Data.Either
which are not available in all library versions Ganeti has
to work on.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent b891d365
......@@ -42,6 +42,7 @@ module Ganeti.BasicTypes
, justOk
, justBad
, eitherToResult
, isLeft
, annotateResult
, annotateError
, failError
......@@ -274,6 +275,12 @@ eitherToResult :: Either a b -> GenericResult a b
eitherToResult (Left s) = Bad s
eitherToResult (Right v) = Ok v
-- | Check if an either is Left. Equivalent to isLeft from Data.Either
-- version 4.7.0.0 or higher.
isLeft :: Either a b -> Bool
isLeft (Left _) = True
isLeft _ = False
-- | Annotate an error with an ownership information, lifting it to a
-- 'MonadError'. Since 'Result' is an instance of 'MonadError' itself,
-- it's a generalization of type @String -> Result a -> Result a@.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment