[commit: packages/containers] merge-fixes-5.9: Fix Read1 and Show1 instance for Tree (58f68bb)

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


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

On branch  : merge-fixes-5.9
Link       : http://git.haskell.org/packages/containers.git/commitdiff/58f68bb25dbefc71ba48a9369e018afb194ec6aa

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

commit 58f68bb25dbefc71ba48a9369e018afb194ec6aa
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


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

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

diff --git a/Data/Tree.hs b/Data/Tree.hs
index 89dd42b..bd9d58a 100644
--- a/Data/Tree.hs
+++ b/Data/Tree.hs
@@ -100,13 +100,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