ganeti-htoolsSource codeContentsIndex
Ganeti.BasicTypes
Contents
Misc functionality
Lookup of partial names functionality
Synopsis
data Result a
= Bad String
| Ok a
isOk :: Result a -> Bool
isBad :: Result a -> Bool
eitherToResult :: Either String a -> Result a
annotateResult :: String -> Result a -> Result a
annotateIOError :: String -> IOError -> IO (Result a)
select :: a -> [(Bool, a)] -> a
data MatchPriority
= ExactMatch
| MultipleMatch
| PartialMatch
| FailMatch
data LookupResult = LookupResult {
lrMatchPriority :: MatchPriority
lrContent :: String
}
prefixMatch :: String -> String -> Bool
goodMatchPriority :: MatchPriority -> Bool
goodLookupResult :: LookupResult -> Bool
compareNameComponent :: String -> String -> LookupResult
chooseLookupResult :: String -> String -> LookupResult -> LookupResult
lookupName :: [String] -> String -> LookupResult
Documentation
data Result a Source

This is similar to the JSON library Result type - very similar, but we want to use it in multiple places, so we abstract it into a mini-library here.

The failure value for this monad is simply a string.

Constructors
Bad String
Ok a
isOk :: Result a -> BoolSource
Simple checker for whether a Result is OK.
isBad :: Result a -> BoolSource
Simple checker for whether a Result is a failure.
eitherToResult :: Either String a -> Result aSource
Converter from Either String to Result.
annotateResult :: String -> Result a -> Result aSource
Annotate a Result with an ownership information.
annotateIOError :: String -> IOError -> IO (Result a)Source
Annotates and transforms IOErrors into a Result type. This can be used in the error handler argument to catch, for example.
Misc functionality
selectSource
::
=> alist of "condition, result"
-> [(Bool, a)]first result which has a True condition, or default
-> a
Return the first result with a True condition, or the default otherwise.
Lookup of partial names functionality
data MatchPriority Source
The priority of a match in a lookup result.
Constructors
ExactMatch
MultipleMatch
PartialMatch
FailMatch
data LookupResult Source
The result of a name lookup in a list.
Constructors
LookupResult
lrMatchPriority :: MatchPriorityThe result type | Matching value (for ExactMatch, PartialMatch), Lookup string otherwise
lrContent :: String
prefixMatchSource
:: StringLookup
-> StringFull name
-> BoolWhether there is a prefix match
Check for prefix matches in names. Implemented in Ganeti core utils.text.MatchNameComponent as the regexp r^%s(..*)?$ % re.escape(key)
goodMatchPriority :: MatchPriority -> BoolSource
Is the lookup priority a good one?
goodLookupResult :: LookupResult -> BoolSource
Is the lookup result an actual match?
compareNameComponentSource
:: StringCanonical (target) name
-> StringPartial (lookup) name
-> LookupResultResult of the lookup
Compares a canonical name and a lookup string.
chooseLookupResultSource
:: StringLookup key
-> StringString to compare to the lookup key
-> LookupResultPrevious result
-> LookupResultNew result
Lookup a string and choose the best result.
lookupNameSource
:: [String]List of keys
-> StringLookup string
-> LookupResultResult of the lookup
Find the canonical name for a lookup string in a list of names.
Produced by Haddock version 2.6.0