Revision e7724ccc Ganeti/HTools/Container.hs
b/Ganeti/HTools/Container.hs | ||
---|---|---|
105 | 105 |
|
106 | 106 |
-- | Find an element by name in a Container; this is a very slow function. |
107 | 107 |
findByName :: (T.Element a, Monad m) => |
108 |
Container a -> String -> m Key
|
|
108 |
Container a -> String -> m a
|
|
109 | 109 |
findByName c n = |
110 | 110 |
let all_elems = elems c |
111 | 111 |
result = filter ((== n) . T.nameOf) all_elems |
112 |
nems = length result |
|
113 |
in |
|
114 |
if nems /= 1 then |
|
115 |
fail $ "Wrong number of elems (" ++ show nems ++ |
|
116 |
") found with name " ++ n |
|
117 |
else |
|
118 |
return $ T.idxOf $ head result |
|
112 |
in case result of |
|
113 |
[item] -> return item |
|
114 |
_ -> fail $ "Wrong number of elems found with name " ++ n |
Also available in: Unified diff