diff --git a/src/Ganeti/BasicTypes.hs b/src/Ganeti/BasicTypes.hs index f74b139d89660ef88a0b442c1b777a1166929709..80b38fc346d4415450919b3a409bed510efe6b1e 100644 --- a/src/Ganeti/BasicTypes.hs +++ b/src/Ganeti/BasicTypes.hs @@ -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@.