on 62_python_dbapi help sign in
21 lines 1.0 kB history raw
1module ProjectM36.TransactionGraph.Show where
2import ProjectM36.Base
3import ProjectM36.TransactionGraph
4import ProjectM36.Transaction
5import qualified Data.Set as S
7showTransactionStructure :: Transaction -> TransactionGraph -> String
8showTransactionStructure trans graph = headInfo ++ " " ++ show (transactionId trans) ++ " p" ++ parentTransactionsInfo ++ " c" ++ childTransactionsInfo
9 where
10 headInfo = maybe "" show (headNameForTransaction trans graph)
11 parentTransactionsInfo = if isRootTransaction trans graph then "root" else case parentTransactions trans graph of
12 Left err -> show err
13 Right parentTransSet -> concat $ S.toList $ S.map (show . transactionId) parentTransSet
14 childTransactionsInfo = show (S.toList (transactionChildIds trans))
16showGraphStructure :: TransactionGraph -> String
17showGraphStructure graph@(TransactionGraph _ transSet) = S.foldr folder "" transSet
18 where
19 folder trans acc = acc ++ showTransactionStructure trans graph ++ "\n"