Skip to content

Commit 96d52fe

Browse files
committed
remove duplicates
1 parent b8facf4 commit 96d52fe

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

gibbon-compiler/src/Gibbon/Passes/OptimizeADTLayout.hs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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]
11931193
deleteMany [] = id -- Nothing to delete
11941194
deleteMany (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+
11961201
fillminus1 :: [Int] -> [Int] -> [Int]
11971202
fillminus1 lst indices =
11981203
case lst of

0 commit comments

Comments
 (0)