Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- properMutualGroups :: (Ord r, Pretty r, Foldable t) => (a -> Maybe r) -> Map r (t a) -> Either [String] [[r]]
- mutualGroups :: (Ord r, Pretty r, Foldable t) => (a -> Maybe r) -> Map r (t a) -> Either [String] [[r]]
- transitiveClosure :: (Foldable t, Pretty r, Ord r) => (a -> Maybe r) -> Map r (t a) -> r -> Either [String] [r]
- type Errors = [Error]
- toErrors :: Either Error a -> Either Errors a
- noErrors :: Errors -> Bool
- class Convertible a b where
- convert :: Convertible a b => a -> b
- type ConvertResult a = Either ConvertError a
- data ConvertError :: * = ConvertError {}
- errorToConvertResult :: (Typeable b, Typeable a, Show a) => (a -> Either Error b) -> a -> ConvertResult b
- errorsToConvertResult :: (Typeable b, Typeable a, Show a) => (a -> Either Errors b) -> a -> ConvertResult b
- convertResultToError :: ConvertResult a -> Either Error a
- convertResultToErrors :: ConvertResult a -> Either Errors a
- dotted :: [String] -> String
Dependencies
properMutualGroups :: (Ord r, Pretty r, Foldable t) => (a -> Maybe r) -> Map r (t a) -> Either [String] [[r]] Source #
Return the groups of mutually dependent entities, with more than one component
>>>
properMutualGroups Just (M.fromList [("a",["b","c"]),("b",["a","c"]),("c",[])])
Right [["b","a"]]
mutualGroups :: (Ord r, Pretty r, Foldable t) => (a -> Maybe r) -> Map r (t a) -> Either [String] [[r]] Source #
Return the groups of mutually dependent entities
>>>
mutualGroups Just (M.fromList [("a",["b","c"]),("b",["a","c"]),("c",[])])
Right [["c"],["b","a"]]
transitiveClosure :: (Foldable t, Pretty r, Ord r) => (a -> Maybe r) -> Map r (t a) -> r -> Either [String] [r] Source #
Return the transitive closure of an element in a graph of dependencies specified as an adjacency list
>>>
transitiveClosure Just (M.fromList [("a",["b","c"]),("b",["b","d","d","c"]),("c",[]),("d",["a"])]) "b"
Right ["c","a","d","b"]
>>>
transitiveClosure Just (M.fromList [("a",["b","c"]),("b",["b","d","d","c"]),("c",[]),("d",["a"])]) "c"
Right ["c"]
Error utilities
toErrors :: Either Error a -> Either Errors a Source #
Either an error or a valid value type EitherError a = Either String a
Either errors or a valid value type EitherErrors a = Either [String] a
Convertible utilities
class Convertible a b where #
A typeclass that represents something that can be converted.
A Convertible a b
instance represents an a
that can be converted to a b
.
safeConvert :: a -> ConvertResult b #
Convert a
to b
, returning Right on success and Left on error.
For a simpler interface, see convert
.
convert :: Convertible a b => a -> b #
Convert from one type of data to another. Raises an exception if there is
an error with the conversion. For a function that does not raise an exception
in that case, see safeConvert
.
type ConvertResult a = Either ConvertError a #
The result of a safe conversion via safeConvert
.
errorToConvertResult :: (Typeable b, Typeable a, Show a) => (a -> Either Error b) -> a -> ConvertResult b Source #
errorsToConvertResult :: (Typeable b, Typeable a, Show a) => (a -> Either Errors b) -> a -> ConvertResult b Source #
convertResultToError :: ConvertResult a -> Either Error a Source #
convertResultToErrors :: ConvertResult a -> Either Errors a Source #
Formatting utilities
dotted :: [String] -> String Source #
Intercalate a dot between the non empty elements of a list of strings.
>>>
dotted []
""
>>>
dotted ["","bc","de"]
"bc.de"
>>>
dotted ["bc","","de"]
"bc.de"