Using quadtrees in a project like so:
data Node = A | B | C deriving (Show)
data QuadTree = Null | Node Node (QuadTree) (QuadTree) (QuadTree) (QuadTree)
deriving Show
These quadtrees are expected to be of up to depth 5 and as you can imagine it very quickly becomes hard to understand the contents of the tree when just outputting with the derived Show.
At depth 1, using derived Show, I'm already working with something like:
Node A (Node B Null Null Null Null) (Node B Null Null Null Null) (Node C Null Null Null Null) (Node B Null Null Null Null)
My current approach to simplifying this output is to use:
toArray (Node x child1 child2 child3 child4) = [x] ++ toArray child1 ++ toArray child2 ++ toArray child3 ++ toArray child4
... which simplifies things a lot: [A, B, B, C, B] in place of the alternative, but still becomes quickly hard to interpret as the tree grows.
Does anyone have any nifty tricks or tips on this they could please share? Any advice is much appreciated.
Edit: to clarify, I just want to be able to see the contents of the tree as any viewable content in the least most migraine inducing way while debugging the algorithms I'll use on the trees





