Revision ea128e20 src/Ganeti/BasicTypes.hs

b/src/Ganeti/BasicTypes.hs
31 31
  , isOk
32 32
  , isBad
33 33
  , justOk
34
  , justBad
34 35
  , eitherToResult
35 36
  , annotateResult
36 37
  , iterateOk
......
51 52
import Control.Monad.Trans
52 53
import Data.Function
53 54
import Data.List
55
import Data.Maybe
54 56
import Data.Set (Set)
55 57
import qualified Data.Set as Set (empty)
56 58
import Text.JSON (JSON)
......
138 140

  
139 141
-- | Simple filter returning only OK values of GenericResult
140 142
justOk :: [GenericResult a b] -> [b]
141
justOk [] = []
142
justOk (x:xs) = case x of
143
  Ok  v -> v:justOk xs
144
  Bad _ -> justOk xs
143
justOk = mapMaybe (genericResult (const Nothing) Just)
144

  
145
-- | Simple filter returning only Bad values of GenericResult
146
justBad :: [GenericResult a b] -> [a]
147
justBad = mapMaybe (genericResult Just (const Nothing))
145 148

  
146 149
-- | Converter from Either to 'GenericResult'.
147 150
eitherToResult :: Either a b -> GenericResult a b

Also available in: Unified diff