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

git at git.haskell.org git at git.haskell.org
Fri Dec 18 22:08:06 UTC 2015


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

On branch  : develop
Link       : http://git.haskell.org/packages/containers.git/commitdiff/2c85f0823848ef7f70a27944bc4741c91ca1c0ef

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

commit 2c85f0823848ef7f70a27944bc4741c91ca1c0ef
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


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

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

diff --git a/Data/Tree.hs b/Data/Tree.hs
index dab25c2..7cfba42 100644
--- a/Data/Tree.hs
+++ b/Data/Tree.hs
@@ -83,15 +83,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