Skip to content

Commit

Permalink
remove duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
vidsinghal committed Oct 18, 2023
1 parent b8facf4 commit 96d52fe
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions gibbon-compiler/src/Gibbon/Passes/OptimizeADTLayout.hs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ genNewProducersAndRewriteProgram
Nothing ->
error "genNewProducersAndRewriteProgram : Program has no main expression."
Just (mexp, ty) ->
let variablesAndProducers = getVariableAndProducer funName pmap venv ddefs newDataConName mexp
let variablesAndProducers = removeDuplicates $ getVariableAndProducer funName pmap venv ddefs newDataConName mexp
in case variablesAndProducers of
[] -> prg --error "no variable and producers found to modify"
[(var, producer)] ->
Expand Down Expand Up @@ -692,10 +692,10 @@ genNewProducersAndRewriteProgram
mainExp = Just (newMainExp, ty)
}
_ -> error ""
x : xs -> error "more than one variable and producer not handled yet."
x : xs -> error ("more than one variable and producer not handled yet." ++ show variablesAndProducers)

-- Function to find the the variable/s that have the type that's being optimized for the given function f
-- Also return the producer of those variable/s
-- Also return the producer of) those variable/s
-- Arguments
-- Var -> Name of the function being optimized
-- pmap -> variable to producer map
Expand Down Expand Up @@ -1193,6 +1193,11 @@ deleteMany :: (Eq a) => [a] -> [a] -> [a]
deleteMany [] = id -- Nothing to delete
deleteMany (x : xs) = deleteMany xs . deleteOne x -- Delete one, then the rest.

removeDuplicates :: Eq a => [a] -> [a]
removeDuplicates list = case list of
[] -> []
a:as -> a:removeDuplicates (P.filter (/=a) as)

fillminus1 :: [Int] -> [Int] -> [Int]
fillminus1 lst indices =
case lst of
Expand Down

0 comments on commit 96d52fe

Please sign in to comment.