model-0.2.4: Derive a model of a data type using Generics

Safe HaskellSafe
LanguageHaskell2010

Data.Model.Util

Synopsis

Documentation

mutualGroups :: (Ord r, Show r, Foldable t) => (a -> Maybe r) -> Map r (t a) -> [[r]] Source #

Return the groups of entities that are mutually dependent

>>> mutualGroups Just (M.fromList [("a",["b","c"]),("b",["a","c"]),("c",[])])
[["c"],["a","b"]]

dependencies :: (Ord r, Show r, Foldable t) => (a -> Maybe r) -> Map r (t a) -> r -> Either Errors [r] Source #

Return a list of the unique recursive dependencies of n in env excluding n, even if self-recursive

>>> dependencies Just (M.fromList [("a",["b","c"]),("b",["b","d","d","c"]),("c",[]),("d",["a"])]) "a"
Right ["b","d","c"]
>>> dependencies Just (M.fromList [("a",["b","c"]),("b",["b","d","d","c"]),("c",[]),("d",["a"])]) "b"
Right ["d","a","c"]