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