Revision 1c7c4578

b/htools/Ganeti/HTools/Types.hs
67 67
    , EvacMode(..)
68 68
    ) where
69 69

  
70
import Control.Monad
70 71
import qualified Data.Map as M
71 72
import qualified Text.JSON as JSON
72 73

  
......
272 273
    return = Ok
273 274
    fail = Bad
274 275

  
276
instance MonadPlus Result where
277
    mzero = Bad "zero Result when used as MonadPlus"
278
    -- for mplus, when we 'add' two Bad values, we concatenate their
279
    -- error descriptions
280
    (Bad x) `mplus` (Bad y) = Bad (x ++ "; " ++ y)
281
    (Bad _) `mplus` x = x
282
    x@(Ok _) `mplus` _ = x
283

  
275 284
-- | Simple checker for whether a 'Result' is OK.
276 285
isOk :: Result a -> Bool
277 286
isOk (Ok _) = True

Also available in: Unified diff