Safe Haskell | Safe-Infered |
---|
- data GenericResult a b
- genericResult :: (a -> c) -> (b -> c) -> GenericResult a b -> c
- type Result = GenericResult String
- class FromString a where
- mkFromString :: String -> a
- newtype ResultT a m b = ResultT {
- runResultT :: m (GenericResult a b)
- resultT :: Monad m => GenericResult a b -> ResultT a m b
- isOk :: GenericResult a b -> Bool
- isBad :: GenericResult a b -> Bool
- eitherToResult :: Either a b -> GenericResult a b
- annotateResult :: String -> Result a -> Result a
- iterateOk :: (a -> GenericResult b a) -> a -> [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 GenericResult a b Source
Generic monad for our error handling mechanisms.
FromString a => Monad (GenericResult a) |
|
Functor (GenericResult a) | |
MonadPlus (GenericResult String) | |
Applicative (GenericResult a) | |
Arbitrary a => Arbitrary (Result a) | |
Arbitrary a => Arbitrary (OpResult a) | |
(Eq a, Eq b) => Eq (GenericResult a b) | |
(Show a, Show b) => Show (GenericResult a b) |
genericResult :: (a -> c) -> (b -> c) -> GenericResult a b -> cSource
Sum type structure of GenericResult.
type Result = GenericResult StringSource
Type alias for a string Result.
class FromString a whereSource
Type class for things that can be built from strings.
mkFromString :: String -> aSource
FromString GanetiException | |
FromString FailMode |
|
FromString [Char] | Trivial |
This is a monad transformation for Result. It's implementation is based on the implementations of MaybeT and ErrorT.
ResultT | |
|
MonadTrans (ResultT a) | |
(Monad m, FromString a) => Monad (ResultT a m) | |
(MonadIO m, FromString a) => MonadIO (ResultT a m) |
isOk :: GenericResult a b -> BoolSource
Simple checker for whether a GenericResult
is OK.
isBad :: GenericResult a b -> BoolSource
Simple checker for whether a GenericResult
is a failure.
eitherToResult :: Either a b -> GenericResult a bSource
Converter from Either to GenericResult
.
annotateResult :: String -> Result a -> Result aSource
Annotate a Result with an ownership information.
iterateOk :: (a -> GenericResult b a) -> a -> [a]Source
Iterate while Ok.
Misc functionality
:: a | default result |
-> [(Bool, a)] | list of "condition, result" |
-> a | first result which has a True condition, or default |
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.
Enum MatchPriority | |
Eq MatchPriority | |
Ord MatchPriority | |
Show MatchPriority |
data LookupResult Source
The result of a name lookup in a list.
LookupResult | |
|
Eq LookupResult | Lookup results have an absolute preference ordering. |
Ord LookupResult | |
Show LookupResult |
:: String | Lookup |
-> String | Full name |
-> Bool | Whether 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?
:: String | Canonical (target) name |
-> String | Partial (lookup) name |
-> LookupResult | Result of the lookup |
Compares a canonical name and a lookup string.
chooseLookupResult :: String -> String -> LookupResult -> LookupResultSource
:: [String] | List of keys |
-> String | Lookup string |
-> LookupResult | Result of the lookup |
Find the canonical name for a lookup string in a list of names.