From caf9da01bf6663854c25fc2cc6457aa4fe7b88cf Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Thu, 19 Apr 2018 12:07:25 +0200 Subject: Fix warnings --- Simplify.hs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'Simplify.hs') diff --git a/Simplify.hs b/Simplify.hs index 9ae29f1..4cb8354 100644 --- a/Simplify.hs +++ b/Simplify.hs @@ -1,19 +1,18 @@ module Simplify (simplify) where import Data.List -import qualified Data.Map.Strict as Map import AST import Utility import Debug -import PrettyPrint +-- import PrettyPrint tracex :: (Show a) => String -> a -> a tracex s x = trace (s ++ ": " ++ show x) x -tracexp :: (PrettyPrint a) => String -> a -> a -tracexp s x = trace (s ++ ": " ++ prettyPrint x) x +-- tracexp :: (PrettyPrint a) => String -> a -> a +-- tracexp s x = trace (s ++ ": " ++ prettyPrint x) x simplify :: [(AST,AST)] -> AST -> AST @@ -33,17 +32,17 @@ flattenSums node = case node of (Sum args) -> case length args of 0 -> Number 0 1 -> flattenSums $ args !! 0 - otherwise -> Sum $ concat $ map (listify . flattenSums) args + _ -> Sum $ concat $ map (listify . flattenSums) args where - listify (Sum args) = args - listify node = [node] + listify (Sum a) = a + listify n = [n] (Product args) -> case length args of 0 -> Number 1 1 -> flattenSums $ args !! 0 - otherwise -> Product $ concat $ map (listify . flattenSums) args + _ -> Product $ concat $ map (listify . flattenSums) args where - listify (Product args) = args - listify node = [node] + listify (Product a) = a + listify n = [n] _ -> node foldNumbers :: AST -> AST @@ -55,7 +54,7 @@ foldNumbers node = case node of _ -> Negative $ fn (Reciprocal n) -> let fn = foldNumbers n in case fn of (Number x) -> Number (1/x) - (Negative n) -> Negative $ Reciprocal fn + (Negative _) -> Negative $ Reciprocal fn (Reciprocal n2) -> n2 _ -> Reciprocal $ fn (Apply name args) -> let fargs = map foldNumbers args @@ -74,7 +73,7 @@ foldNumbers node = case node of foldvalue = func $ map (\(Number n) -> n) nums in case length nums of x | x >= 1 -> if foldvalue == zerovalue then notnums else Number foldvalue : notnums - otherwise -> foldedArgs + _ -> foldedArgs dofoldnegsToProd args = let foldedArgs = map foldNumbers args (negs,notnegs) = partition isneg foldedArgs @@ -88,7 +87,7 @@ foldNumbers node = case node of in case length negs of x | x < 2 -> Product args | even x -> Product unnegged - | odd x -> Product $ Number (-1) : unnegged + | otherwise -> Product $ Number (-1) : unnegged canonicaliseOrder :: AST -> AST canonicaliseOrder node = case node of -- cgit v1.2.3-54-g00ecf