+
+-- | Generates serialized data from loader input
+processData :: Result (Node.AssocList, Instance.AssocList, [String])
+ -> Result (Node.List, Instance.List, String)
+processData input_data = do
+ (nl, il, _) <- input_data >>= Loader.mergeData [] [] []
+ let (_, fix_nl) = Loader.checkData nl il
+ adata = serializeCluster nl il
+ return (fix_nl, il, adata)
+
+-- | Writes cluster data out
+writeData :: Int
+ -> String
+ -> Options
+ -> Result (Node.List, Instance.List, String)
+ -> IO Bool
+writeData _ name _ (Bad err) =
+ printf "\nError for %s: failed to load data. Details:\n%s\n" name err >>
+ return False
+
+writeData nlen name opts (Ok (nl, il, adata)) = do
+ printf "%-*s " nlen name :: IO ()
+ hFlush stdout
+ let shownodes = optShowNodes opts
+ odir = optOutPath opts
+ oname = odir </> fixSlash name
+ putStrLn $ printCluster nl il
+ hFlush stdout
+ when (isJust shownodes) $
+ putStr $ Cluster.printNodes nl (fromJust shownodes)
+ writeFile (oname <.> "data") adata
+ return True
+