-- -----------------------------------------------------------------------------

-- TODO: rediscover what I am doing here
liveness :: IC -> Set.Set Name -> ICLive
liveness ic names = reverse $ analyze (reverse ic) names 
    where 
      analyze [] _ = [] 
      analyze (x@((nom,_) ::= d2):xs) ns = 
          let ns' = Set.delete nom $ (ns `Set.union` getArrayNames d2 )
          in (x, (Set.insert nom ns')) : analyze xs ns'
      analyze (x:xs) ns = (x,ns) : analyze xs ns
liveness :: IC -> Set.Set Name -> ICLive
liveness ic names = reverse $ analyze (reverse ic) names 
    where 
      analyze [] _ = [] 
      analyze (x@((nom,_) ::= d2):xs) ns = 
          let ns' = Set.delete nom $ (ns `Set.union` getArrayNames d2 )
          in (x, (Set.insert nom ns')) : analyze xs ns'
      analyze (x:xs) ns = (x,ns) : analyze xs ns
liveness ic names = reverse $ analyze (reverse ic) names 
    where 
      analyze [] _ = [] 
      analyze (x@((nom,_) ::= d2):xs) ns = 
          let ns' = Set.delete nom $ (ns `Set.union` getArrayNames d2 )
          in (x, (Set.insert nom ns')) : analyze xs ns'
      analyze (x:xs) ns = (x,ns) : analyze xs ns