From: Mark Wooding Date: Sun, 29 Nov 2009 23:26:16 +0000 (+0000) Subject: haskell: Remove some redundant parenthesis. X-Git-Url: https://git.distorted.org.uk/~mdw/fringe/commitdiff_plain/e4e035bf5fd8c6d99eecff9db55cdd4a4b069fbe haskell: Remove some redundant parenthesis. Actually this changes the semantics of the program slightly: Node becomes a (curried) 3-ary constructor rather than a unary constructor accepting a tuple. This is all to the good. --- diff --git a/haskell-fringe.hs b/haskell-fringe.hs index 78c6362..4ca9a3e 100644 --- a/haskell-fringe.hs +++ b/haskell-fringe.hs @@ -58,12 +58,12 @@ eof = do ----------------------------------------------------------------------------- -- Tree data type. -data Tree a = Leaf | Node (Tree a, a, Tree a) deriving (Show) +data Tree a = Leaf | Node (Tree a) a (Tree a) deriving (Show) -- Return the elements inorder, as a list. fringe t = gather t [] where gather Leaf ns = ns - gather (Node (l, x, r)) ns = gather l (x : gather r ns) + gather (Node l x r) ns = gather l (x : gather r ns) -- Answer whether two trees have the same fringe. sameFringe t tt = fringe t == fringe tt -- trivial! @@ -81,7 +81,7 @@ parseTree cs = parse cs $ do t <- tree; eof; return t case r of Just '(' -> do step; left <- tree; c <- anytok "no data"; right <- tree; delim ')' - return $ Node (left, c, right) + return $ Node left c right _ -> return Leaf -----------------------------------------------------------------------------