-- | Like 'unroll', but applied to a network of paths.
unrollSystem :: (Ord c) => c -> System c b e a -> System c b e a
unrollSystem c sys = case Map.lookup c $ systemPaths sys of
  Nothing -> sys
  Just path -> mapPaths (unroll c path) $
    sys { systemPaths = Map.delete c $ systemPaths sys }

-- | Sorts a list, and then returns only elements that appear just once.
unrollSystem :: (Ord c) => c -> System c b e a -> System c b e a
unrollSystem c sys = case Map.lookup c $ systemPaths sys of
  Nothing -> sys
  Just path -> mapPaths (unroll c path) $
    sys { systemPaths = Map.delete c $ systemPaths sys }

-- | Sorts a list, and then returns only elements that appear just once.
unrollSystem c sys = case Map.lookup c $ systemPaths sys of
  Nothing -> sys
  Just path -> mapPaths (unroll c path) $
    sys { systemPaths = Map.delete c $ systemPaths sys }

-- | Sorts a list, and then returns only elements that appear just once.