on ffe683a help sign in
24 lines 963 B history raw
1{-# LANGUAGE OverloadedStrings #-}
2module ProjectM36.TransactionGraph.Show where
3import ProjectM36.Base
4import ProjectM36.TransactionGraph
5import qualified Data.Set as S
8showTransactionStructure :: Transaction -> TransactionGraph -> String
9showTransactionStructure trans graph = headInfo ++ " " ++ show (transactionUUID trans) ++ " " ++ parentTransactionsInfo
10 where
11 headInfo = maybe "" show (headNameForTransaction trans graph)
12 parentTransactionsInfo = if isRootTransaction trans graph then "root" else case parentTransactions trans graph of
13 Left err -> show err
14 Right parentTransSet -> concat $ S.toList $ S.map (show . transactionUUID) parentTransSet
16showGraphStructure :: TransactionGraph -> String
17showGraphStructure graph@(TransactionGraph _ transSet) = S.foldr folder "" transSet
18 where
19 folder trans acc = acc ++ showTransactionStructure trans graph ++ "\n"