-- |Lines are grouped so that all transactions lines for an entry are in the same
-- line group as the entry line.
-- We accomplish this by passing around an extra parameter used to accumulate
-- all the lines for the current group.
groupLines :: LineGroup -> [LineGroup]
groupLines = tail . groupLines' []
    where
      groupLines' cg [] = [cg]
      groupLines' cg (l:ls) | isTrans . snd $ l = groupLines' (cg ++ [l]) ls
                            | otherwise         = cg : groupLines' [l] ls

-- |A transaction is a line that starts with space.
-- This function should not be called on lines that consists only of white space.
groupLines :: LineGroup -> [LineGroup]
groupLines = tail . groupLines' []
    where
      groupLines' cg [] = [cg]
      groupLines' cg (l:ls) | isTrans . snd $ l = groupLines' (cg ++ [l]) ls
                            | otherwise         = cg : groupLines' [l] ls

-- |A transaction is a line that starts with space.
-- This function should not be called on lines that consists only of white space.
groupLines = tail . groupLines' []
    where
      groupLines' cg [] = [cg]
      groupLines' cg (l:ls) | isTrans . snd $ l = groupLines' (cg ++ [l]) ls
                            | otherwise         = cg : groupLines' [l] ls

-- |A transaction is a line that starts with space.
-- This function should not be called on lines that consists only of white space.