From f9000cbf33be242d7f11d162ffada56d65225c3a Mon Sep 17 00:00:00 2001 From: jonasc <github@bcdf.eu> Date: Fri, 8 Aug 2014 00:15:10 +0200 Subject: [PATCH] Make types of the drawing functions more generic, i.e. Show s => Tree s instead of Tree String --- Data/Tree.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Data/Tree.hs b/Data/Tree.hs index a6f64f97..754b4e28 100644 --- a/Data/Tree.hs +++ b/Data/Tree.hs @@ -112,15 +112,15 @@ instance NFData a => NFData (Tree a) where rnf (Node x ts) = rnf x `seq` rnf ts -- | Neat 2-dimensional drawing of a tree. -drawTree :: Tree String -> String +drawTree :: Show a => Tree a -> String drawTree = unlines . draw -- | Neat 2-dimensional drawing of a forest. -drawForest :: Forest String -> String +drawForest :: Show a => Forest a -> String drawForest = unlines . map drawTree -draw :: Tree String -> [String] -draw (Node x ts0) = x : drawSubTrees ts0 +draw :: Show a => Tree a -> [String] +draw (Node x ts0) = show x : drawSubTrees ts0 where drawSubTrees [] = [] drawSubTrees [t] = -- GitLab