Skip to content

Commit

Permalink
Make types of the drawing functions more generic, i.e. Show s => Tree…
Browse files Browse the repository at this point in the history
… s instead of Tree String
  • Loading branch information
jonasc committed Aug 7, 2014
1 parent 3b1eee5 commit e650dda
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Data/Tree.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down

0 comments on commit e650dda

Please sign in to comment.