[commit: packages/containers] develop-0.6: Make types of the drawing functions more generic, i.e. Show s => Tree s instead of Tree String (7ab1c39)

git at git.haskell.org git at git.haskell.org
Mon Apr 17 21:36:19 UTC 2017


Repository : ssh://git@git.haskell.org/containers

On branch  : develop-0.6
Link       : http://git.haskell.org/packages/containers.git/commitdiff/7ab1c399726c5a4a562cff3f56017ff5852ac82e

>---------------------------------------------------------------

commit 7ab1c399726c5a4a562cff3f56017ff5852ac82e
Author: jonasc <github at bcdf.eu>
Date:   Fri Aug 8 00:15:10 2014 +0200

    Make types of the drawing functions more generic, i.e. Show s => Tree s instead of Tree String


>---------------------------------------------------------------

7ab1c399726c5a4a562cff3f56017ff5852ac82e
 Data/Tree.hs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Data/Tree.hs b/Data/Tree.hs
index 57a4324..1642c3b 100644
--- a/Data/Tree.hs
+++ b/Data/Tree.hs
@@ -113,15 +113,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] =



More information about the ghc-commits mailing list