[commit: packages/containers] cleaned_bugfix394, master, merge-doc-target, revert-408-bugfix_394: Fix Read1 and Show1 instance for Tree (9170603)

git at git.haskell.org git at git.haskell.org
Mon Apr 17 21:47:14 UTC 2017


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

On branches: cleaned_bugfix394,master,merge-doc-target,revert-408-bugfix_394
Link       : http://git.haskell.org/packages/containers.git/commitdiff/917060374023a525a4c136f5c7d8a82feb2a67b0

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

commit 917060374023a525a4c136f5c7d8a82feb2a67b0
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Sat Jan 7 22:34:32 2017 -0500

    Fix Read1 and Show1 instance for Tree


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

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

diff --git a/Data/Tree.hs b/Data/Tree.hs
index 5a9ad20..538d2f3 100644
--- a/Data/Tree.hs
+++ b/Data/Tree.hs
@@ -104,13 +104,13 @@ instance Ord1 Tree where
       lcomp (Node a fr) (Node a' fr') = cmp a a' <> liftCompare lcomp fr fr'
 
 instance Show1 Tree where
-  liftShowsPrec shw shwl _p (Node a fr) =
+  liftShowsPrec shw shwl p (Node a fr) = showParen (p > 10) $
         showString "Node {rootLabel = " . shw 0 a . showString ", " .
           showString "subForest = " . liftShowList shw shwl fr .
           showString "}"
 
 instance Read1 Tree where
-  liftReadsPrec rd rdl _p = readParen False $
+  liftReadsPrec rd rdl p = readParen (p > 10) $
     \s -> do
       ("Node", s1) <- lex s
       ("{", s2) <- lex s1



More information about the ghc-commits mailing list