Revision a1da8a50 src/Ganeti/BasicTypes.hs
b/src/Ganeti/BasicTypes.hs | ||
---|---|---|
48 | 48 |
, handleErrorT |
49 | 49 |
, iterateOk |
50 | 50 |
, select |
51 |
, runListHead |
|
51 | 52 |
, LookupResult(..) |
52 | 53 |
, MatchPriority(..) |
53 | 54 |
, lookupName |
... | ... | |
312 | 313 |
-> a -- ^ first result which has a True condition, or default |
313 | 314 |
select def = maybe def snd . find fst |
314 | 315 |
|
316 |
-- | Apply a function to the first element of a list, return the default |
|
317 |
-- value, if the list is empty. This is just a convenient combination of |
|
318 |
-- maybe and listToMaybe. |
|
319 |
runListHead :: a -> (b -> a) -> [b] -> a |
|
320 |
runListHead a f = maybe a f . listToMaybe |
|
321 |
|
|
315 | 322 |
-- * Lookup of partial names functionality |
316 | 323 |
|
317 | 324 |
-- | The priority of a match in a lookup result. |
Also available in: Unified diff