# Data.Graph.Inductive: exported symbols usage examples

## Symbols

- edges Collapse [-]Found in Drifter.Graph from the package drifter
labUEdges :: [Edge] -> [UEdge] labUEdges = map (\(a, b) -> (a, b, ())) -- | Take an unordered list of changes and put them in dependency -- order. 'migrate' will do this automatically. resolveDependencyOrder :: [Change a] -> [Change a] resolveDependencyOrder cs = topsort' $ graphDependencies cs graphDependencies :: [Change a] -> Gr (Change a) () graphDependencies cs = mkGraph nodes (labUEdges edges) where nodes = zip [1..] cs nMap = Map.fromList $ map (\(i, c) -> (changeName c, i)) nodes edges = catMaybes $ map (\(a, b) -> (,) <$> a <*> b) $ concat $ map (\c -> map (\dn -> ( Map.lookup dn nMap , Map.lookup (changeName c) nMap)) (changeDependencies c))

Found in Drifter.Graph from the package drifter------------------------------------------------------------------------------- import Drifter.Types ------------------------------------------------------------------------------- labUEdges :: [Edge] -> [UEdge] labUEdges = map (\(a, b) -> (a, b, ())) -- | Take an unordered list of changes and put them in dependency -- order. 'migrate' will do this automatically. resolveDependencyOrder :: [Change a] -> [Change a] resolveDependencyOrder cs = topsort' $ graphDependencies cs graphDependencies :: [Change a] -> Gr (Change a) () graphDependencies cs = mkGraph nodes (labUEdges edges) where nodes = zip [1..] cs nMap = Map.fromList $ map (\(i, c) -> (changeName c, i)) nodes edges = catMaybes $ map (\(a, b) -> (,) <$> a <*> b) $ concat

nodes Collapse [-]Found in Drifter.Graph from the package drifter------------------------------------------------------------------------------- labUEdges :: [Edge] -> [UEdge] labUEdges = map (\(a, b) -> (a, b, ())) -- | Take an unordered list of changes and put them in dependency -- order. 'migrate' will do this automatically. resolveDependencyOrder :: [Change a] -> [Change a] resolveDependencyOrder cs = topsort' $ graphDependencies cs graphDependencies :: [Change a] -> Gr (Change a) () graphDependencies cs = mkGraph nodes (labUEdges edges) where nodes = zip [1..] cs nMap = Map.fromList $ map (\(i, c) -> (changeName c, i)) nodes edges = catMaybes $ map (\(a, b) -> (,) <$> a <*> b) $ concat $ map (\c -> map (\dn -> ( Map.lookup dn nMap , Map.lookup (changeName c) nMap))

Found in Drifter.Graph from the package drifterimport Drifter.Types ------------------------------------------------------------------------------- labUEdges :: [Edge] -> [UEdge] labUEdges = map (\(a, b) -> (a, b, ())) -- | Take an unordered list of changes and put them in dependency -- order. 'migrate' will do this automatically. resolveDependencyOrder :: [Change a] -> [Change a] resolveDependencyOrder cs = topsort' $ graphDependencies cs graphDependencies :: [Change a] -> Gr (Change a) () graphDependencies cs = mkGraph nodes (labUEdges edges) where nodes = zip [1..] cs nMap = Map.fromList $ map (\(i, c) -> (changeName c, i)) nodes edges = catMaybes $ map (\(a, b) -> (,) <$> a <*> b) $ concat $ map (\c -> map (\dn -> ( Map.lookup dn nMap

Found in Drifter.Graph from the package drifter------------------------------------------------------------------------------- import Drifter.Types ------------------------------------------------------------------------------- labUEdges :: [Edge] -> [UEdge] labUEdges = map (\(a, b) -> (a, b, ())) -- | Take an unordered list of changes and put them in dependency -- order. 'migrate' will do this automatically. resolveDependencyOrder :: [Change a] -> [Change a] resolveDependencyOrder cs = topsort' $ graphDependencies cs graphDependencies :: [Change a] -> Gr (Change a) () graphDependencies cs = mkGraph nodes (labUEdges edges) where nodes = zip [1..] cs nMap = Map.fromList $ map (\(i, c) -> (changeName c, i)) nodes edges = catMaybes $ map (\(a, b) -> (,) <$> a <*> b) $ concat

topsort' Collapse [-]Found in Drifter.Graph from the package drifterimport Data.Graph.Inductive (Edge, Gr, UEdge, mkGraph, topsort') import qualified Data.Map.Strict as Map import Data.Maybe ------------------------------------------------------------------------------- import Drifter.Types ------------------------------------------------------------------------------- labUEdges :: [Edge] -> [UEdge] labUEdges = map (\(a, b) -> (a, b, ())) -- | Take an unordered list of changes and put them in dependency -- order. 'migrate' will do this automatically. resolveDependencyOrder :: [Change a] -> [Change a] resolveDependencyOrder cs = topsort' $ graphDependencies cs graphDependencies :: [Change a] -> Gr (Change a) () graphDependencies cs = mkGraph nodes (labUEdges edges) where nodes = zip [1..] cs nMap = Map.fromList $ map (\(i, c) -> (changeName c, i)) nodes

Found in Drifter.Graph from the package driftermodule Drifter.Graph ( resolveDependencyOrder , Drifter(..) , migrate ) where ------------------------------------------------------------------------------- import Control.Applicative as A import Control.Monad import Data.Graph.Inductive (Edge, Gr, UEdge, mkGraph, topsort') import qualified Data.Map.Strict as Map import Data.Maybe ------------------------------------------------------------------------------- import Drifter.Types -------------------------------------------------------------------------------

mf Collapse [-]Found in Drifter.Graph from the package drifterwhere cs = resolveDependencyOrder csUnsorted go = EitherT . migrateSingle conn newtype EitherT e m a = EitherT { runEitherT :: m (Either e a) } instance Monad m => Functor (EitherT e m) where fmap f = EitherT . liftM (fmap f) . runEitherT {-# INLINE fmap #-} instance Monad m => A.Applicative (EitherT e m) where pure a = EitherT $ return (Right a) {-# INLINE pure #-} EitherT f <*> EitherT v = EitherT $ f >>= \mf -> case mf of Left e -> return (Left e) Right k -> v >>= \mv -> case mv of Left e -> return (Left e) Right x -> return (Right (k x)) {-# INLINE (<*>) #-}

Found in Drifter.Graph from the package drifterwhere cs = resolveDependencyOrder csUnsorted go = EitherT . migrateSingle conn newtype EitherT e m a = EitherT { runEitherT :: m (Either e a) } instance Monad m => Functor (EitherT e m) where fmap f = EitherT . liftM (fmap f) . runEitherT {-# INLINE fmap #-} instance Monad m => A.Applicative (EitherT e m) where pure a = EitherT $ return (Right a) {-# INLINE pure #-} EitherT f <*> EitherT v = EitherT $ f >>= \mf -> case mf of Left e -> return (Left e) Right k -> v >>= \mv -> case mv of Left e -> return (Left e) Right x -> return (Right (k x)) {-# INLINE (<*>) #-}