@@ -642,7 +642,7 @@ genNewProducersAndRewriteProgram
642642 Nothing ->
643643 error " genNewProducersAndRewriteProgram : Program has no main expression."
644644 Just (mexp, ty) ->
645- let variablesAndProducers = getVariableAndProducer funName pmap venv ddefs newDataConName mexp
645+ let variablesAndProducers = removeDuplicates $ getVariableAndProducer funName pmap venv ddefs newDataConName mexp
646646 in case variablesAndProducers of
647647 [] -> prg -- error "no variable and producers found to modify"
648648 [(var, producer)] ->
@@ -692,10 +692,10 @@ genNewProducersAndRewriteProgram
692692 mainExp = Just (newMainExp, ty)
693693 }
694694 _ -> error " "
695- x : xs -> error " more than one variable and producer not handled yet."
695+ x : xs -> error ( " more than one variable and producer not handled yet." ++ show variablesAndProducers)
696696
697697-- Function to find the the variable/s that have the type that's being optimized for the given function f
698- -- Also return the producer of those variable/s
698+ -- Also return the producer of) those variable/s
699699-- Arguments
700700-- Var -> Name of the function being optimized
701701-- pmap -> variable to producer map
@@ -1193,6 +1193,11 @@ deleteMany :: (Eq a) => [a] -> [a] -> [a]
11931193deleteMany [] = id -- Nothing to delete
11941194deleteMany (x : xs) = deleteMany xs . deleteOne x -- Delete one, then the rest.
11951195
1196+ removeDuplicates :: Eq a => [a ] -> [a ]
1197+ removeDuplicates list = case list of
1198+ [] -> []
1199+ a: as -> a: removeDuplicates (P. filter (/= a) as)
1200+
11961201fillminus1 :: [Int ] -> [Int ] -> [Int ]
11971202fillminus1 lst indices =
11981203 case lst of
0 commit comments